Showing AI reviews for bet-service
Project AI Score ?
62%
Quality Avg ?
63%
Security Avg ?
59%
Reviews ?
92

Review Result ?

solutionbowl/bet-service · f753dfb0
The commit adds comments clarifying handling of confirmed amounts from multiple bet legs which settle out of order. However, actual code changes are not shown, limiting visible impact. Comments improve code readability but no direct code improvement or bug fixes are evident.
Quality ?
40%
Security ?
90%
Business Value ?
30%
Maintainability ?
35%
Issues & Suggested Fixes ?
1AI detects the issue
2Shows file, line, or evidence
3Suggests the fix to apply
Vague And Non Descriptive
Where commit message
Issue / Evidence vague and non-descriptive
Suggested Fix improve commit message to clearly explain the change and its business value
Comment Only Addition
Where src/utils/multiBetExposure.js:17
Issue / Evidence comment only addition
Suggested Fix ensure code changes accompany comments to increase impact
Comment Only Addition
Where src/utils/multiBetExposure.js:18
Issue / Evidence comment only addition
Suggested Fix add tests validating handling of out-of-order leg settlements
Comment Only Addition
Where src/utils/multiBetExposure.js:24
Issue / Evidence comment only addition
Suggested Fix consider adding error handling for unexpected bet leg states
Code Change Preview · src/utils/multiBetExposure.js ?
Removed / Before Commit
- diff --git a/src/utils/multiBetExposure.js b/src/utils/multiBetExposure.js
- index d0ae2c6..31dd545 100644
- ? Number(options.forceWonLegNumber)
- : null;
- 
-     // Calculate confirmed amount up to last won leg
- const sortedLegs = await RacingBet.find({ bet_id: betId })
- .sort({ leg_number: 1 });
- 
- let confirmedAmount = originalStake;
- 
-     // Find last won leg
- for (const leg of sortedLegs) {
- const legStatus = forceWonLegNumber === Number(leg.leg_number)
- ? "WON"
- } else if (legStatus === "LOST") {
- // If any leg lost, no exposures
- return;
Added / After Commit
+ diff --git a/src/utils/multiBetExposure.js b/src/utils/multiBetExposure.js
+ index d0ae2c6..31dd545 100644
+ ? Number(options.forceWonLegNumber)
+ : null;
+ 
+     // Calculate confirmed amount from every won leg. Races can settle out of
+     // leg_number order, so do not stop at the first pending leg.
+ const sortedLegs = await RacingBet.find({ bet_id: betId })
+ .sort({ leg_number: 1 });
+ 
+ let confirmedAmount = originalStake;
+ 
+     // Include all already won legs in the cascading amount.
+ for (const leg of sortedLegs) {
+ const legStatus = forceWonLegNumber === Number(leg.leg_number)
+ ? "WON"
+ } else if (legStatus === "LOST") {
+ // If any leg lost, no exposures