AI Review Center
Commit Review Workspace ?
Select a commit on the left to inspect quality, security, business value, findings, and suggested code changes.
Project AI Score
?
72%
Quality Avg
?
77%
Security Avg
?
64%
Reviews
?
91
Review Result ?
solutionbowl/super-admin · 8a6ae6e2
The commit adds functionality to fetch and normalize net bets data from an API, integrating it with existing queries using useQuery React hooks. The normalization function robustly handles varying key names and data shapes. Some duplication exists between two files (net-exposure-detail.tsx and user-exposure-detail.tsx) with highly similar normalization and fetching logic. The code introduces detailed mapping of bet data fields improving data handling quality and robustness. However, there is limited input validation beyond type coercion, and userId extraction differs between files without clear consistency. Error handling in async calls is not evident. The commit message is sparse, providing no context.
Quality
?
85%
Security
?
50%
Business Value
?
70%
Maintainability
?
85%
Issues & Suggested Fixes
?
1AI detects the issue
2Shows file, line, or evidence
3Suggests the fix to apply
Lack Of Detail
Where
commit message
Issue / Evidence
lack of detail
Suggested Fix
improve commit message to describe functionality and purpose clearly
Normalization Function
Where
src/routes/net-exposure-detail.tsx:1070
Issue / Evidence
normalization function
Suggested Fix
consider adding error handling or validation for payload structure to reduce bug risk
Fetch Net Bets
Where
src/routes/net-exposure-detail.tsx:152
Issue / Evidence
fetchNetBets
Suggested Fix
add try/catch or error state handling for tenantApiClient.post calls to improve robustness
Inconsistent Userid Extraction
Where
src/routes/user-exposure-detail.tsx:1128
Issue / Evidence
inconsistent userId extraction
Suggested Fix
standardize method to ensure consistent data handling and reduce bugs
Duplicate Logic
Where
src/routes/user-exposure-detail.tsx:1116
Issue / Evidence
normalization duplication
Suggested Fix
refactor common normalization logic into shared module to reduce code duplication and maintenance burden
Get Array
Where
src/routes/net-exposure-detail.tsx:1142
Issue / Evidence
getArray
Suggested Fix
consider checking for null/undefined inputs explicitly before Array.isArray to improve defensive programming
Get Array
Where
src/routes/user-exposure-detail.tsx:1203
Issue / Evidence
getArray
Suggested Fix
same as above for consistency
Usequery Options
Where
src/routes/net-exposure-detail.tsx:217
Issue / Evidence
useQuery options
Suggested Fix
currently always refetchOnMount and staleTime 0; consider caching or stale data strategies depending on business requirements to optimize performance
Usequery Options
Where
src/routes/user-exposure-detail.tsx:227
Issue / Evidence
useQuery options
Suggested Fix
same as above
Code Change Preview · src/routes/net-exposure-detail.tsx
?
Removed / Before Commit
- diff --git a/src/routes/net-exposure-detail.tsx b/src/routes/net-exposure-detail.tsx - index da1c9d1..3505bc2 100644 - marketId: string, - parentUserId?: string, - ): Promise<DetailData> { - const res = (await tenantApiClient.post<unknown>("/horse-racing/reports/net-exposure/detail", { - raceId, - marketId, - ...(parentUserId ? { parentUserId } : {}), - return (res?.data ?? res) as DetailData; - } - - async function fetchOdds(raceId: string): Promise<OddsMarket[]> { - const res = (await tenantApiClient.get<unknown>(`/owner/races/${raceId}/odds`)) as Record< - string, - staleTime: 0, - }); -
Added / After Commit
+ diff --git a/src/routes/net-exposure-detail.tsx b/src/routes/net-exposure-detail.tsx + index da1c9d1..3505bc2 100644 + marketId: string, + parentUserId?: string, + ): Promise<DetailData> { + const res = (await tenantApiClient.post<unknown>("/horse-racing/reports/get_market_net_exposure", { + raceId, + marketId, + ...(parentUserId ? { parentUserId } : {}), + return (res?.data ?? res) as DetailData; + } + + async function fetchNetBets( + raceId: string, + marketId: string, + parentUserId?: string, + ): Promise<Bet[]> { + const res = await tenantApiClient.post<unknown>("/horse-racing/reports/get_net_bets", {
Removed / Before Commit
- diff --git a/src/routes/user-exposure-detail.tsx b/src/routes/user-exposure-detail.tsx - index 2450e90..fc701d4 100644 - marketId: string, - parentUserId?: string, - ): Promise<DetailData> { - const res = (await tenantApiClient.post<unknown>("/horse-racing/reports/net-exposure/detail", { - raceId, - marketId, - ...(parentUserId ? { parentUserId } : {}), - return (res?.data ?? res) as DetailData; - } - - async function fetchOdds(raceId: string): Promise<OddsMarket[]> { - const res = (await tenantApiClient.get<unknown>(`/owner/races/${raceId}/odds`)) as Record< - string, - staleTime: 0, - }); -
Added / After Commit
+ diff --git a/src/routes/user-exposure-detail.tsx b/src/routes/user-exposure-detail.tsx + index 2450e90..fc701d4 100644 + marketId: string, + parentUserId?: string, + ): Promise<DetailData> { + const res = (await tenantApiClient.post<unknown>("/horse-racing/reports/get_market_net_exposure", { + raceId, + marketId, + ...(parentUserId ? { parentUserId } : {}), + return (res?.data ?? res) as DetailData; + } + + async function fetchNetBets( + raceId: string, + marketId: string, + parentUserId?: string, + ): Promise<Bet[]> { + const res = await tenantApiClient.post<unknown>("/horse-racing/reports/get_net_bets", {
Removed / Before Commit
- diff --git a/src/services/api/resourceService.ts b/src/services/api/resourceService.ts - index 95582fc..a6b9b18 100644 - update: (id: string, payload: TUpdate) => Promise<TRecord>; - remove: (id: string) => Promise<void>; - } - - function toQueryString(params?: ListParams) { - if (!params) return ""; - const searchParams = new URLSearchParams();
Added / After Commit
+ diff --git a/src/services/api/resourceService.ts b/src/services/api/resourceService.ts + index 95582fc..a6b9b18 100644 + update: (id: string, payload: TUpdate) => Promise<TRecord>; + remove: (id: string) => Promise<void>; + } + + function toQueryString(params?: ListParams) { + if (!params) return ""; + const searchParams = new URLSearchParams();