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
?
62%
Quality Avg
?
63%
Security Avg
?
59%
Reviews
?
92
Review Result ?
solutionbowl/bet-service · d19fb2c1
The commit improves business logic by adding validations and extending the data model with more detailed betting leg attributes. It introduces clearer bet type determination and enhances profit and deduction handling. The changes are generally positive for business value and code quality with low risk of bugs or security issues.
Quality
?
80%
Security
?
70%
Business Value
?
85%
Maintainability
?
80%
Issues & Suggested Fixes
?
1AI detects the issue
2Shows file, line, or evidence
3Suggests the fix to apply
Missing Validation
Where
src/controllers/multiBet.controller.js:54
Issue / Evidence
validation logic does not specify exact error handling behavior
Suggested Fix
add explicit error responses or logging for invalid selections to improve debugging and reliability
Missing Validation
Where
src/models/RacingBet.js:17
Issue / Evidence
numeric fields default to 0 but range or validation constraints are missing
Suggested Fix
implement validation for these numeric fields to ensure data integrity
Missing Validation
Where
src/utils/multiBetExposure.js:39
Issue / Evidence
usage of Number() conversion without input validation could lead to unexpected NaN
Suggested Fix
add input validation or sanitization before conversion to improve robustness
Vague Summary 'Ledger' Does Not Explain Th...
Where
commit message
Issue / Evidence
vague summary 'ledger' does not explain the purpose or scope of the changes
Suggested Fix
write a clearer, more descriptive commit message to enhance traceability
Code Change Preview · src/controllers/multiBet.controller.js
?
Removed / Before Commit
- diff --git a/src/controllers/multiBet.controller.js b/src/controllers/multiBet.controller.js - index 22001d8..8388b90 100644 - }); - } - - if (selections.length < 1 || selections.length > 3) { - return res.status(400).json({ - status: false, - message: "Selections must be between 1-3 races (STRAIGHT/DOUBLE/TRIPLE)" - }); - } - - if (selections.length === 1) betType = "STRAIGHT"; - else if (selections.length === 2) betType = "DOUBLE"; - else if (selections.length === 3) betType = "TRIPLE"; - - // Calculate potential profit using CASCADING method (net odds) - // Multi-bet uses net odds (profit multipliers), not decimal odds
Added / After Commit
+ diff --git a/src/controllers/multiBet.controller.js b/src/controllers/multiBet.controller.js + index 22001d8..8388b90 100644 + }); + } + + if (selections.length < 1 || selections.length > 10) { + return res.status(400).json({ + status: false, + message: "Selections must be between 1-10 races" + }); + } + + if (selections.length === 1) betType = "STRAIGHT"; + else if (selections.length === 2) betType = "DOUBLE"; + else if (selections.length === 3) betType = "TRIPLE"; + else betType = `${selections.length}_FOLD`; + + // Calculate potential profit using CASCADING method (net odds)
Removed / Before Commit
- diff --git a/src/models/Bet.js b/src/models/Bet.js - index cdd0112..74e58be 100644 - is_multi_bet: { type: Boolean, default: false }, - multi_bet_type: { - type: String, - enum: ["STRAIGHT", "DOUBLE", "TRIPLE", null], - default: null - }, - total_legs: { type: Number, default: 1 },
Added / After Commit
+ diff --git a/src/models/Bet.js b/src/models/Bet.js + index cdd0112..74e58be 100644 + is_multi_bet: { type: Boolean, default: false }, + multi_bet_type: { + type: String, + enum: ["STRAIGHT", "DOUBLE", "TRIPLE", "4_FOLD", "5_FOLD", "6_FOLD", "7_FOLD", "8_FOLD", "9_FOLD", "10_FOLD", null], + default: null + }, + total_legs: { type: Number, default: 1 },
Removed / Before Commit
- diff --git a/src/models/RacingBet.js b/src/models/RacingBet.js - index d049332..d87f7d4 100644 - // Multi-bet support - leg_number: { type: Number, default: 1 }, - position: { type: Number, default: 1 }, - leg_status: { - type: String, - enum: ["PENDING", "WON", "LOST", "VOID", "WITHDRAWN"],
Added / After Commit
+ diff --git a/src/models/RacingBet.js b/src/models/RacingBet.js + index d049332..d87f7d4 100644 + // Multi-bet support + leg_number: { type: Number, default: 1 }, + position: { type: Number, default: 1 }, + stake_at_leg: { type: Number, default: 0 }, + gross_profit: { type: Number, default: 0 }, + deduction_percent: { type: Number, default: 0 }, + deduction_amount: { type: Number, default: 0 }, + net_profit: { type: Number, default: 0 }, + leg_status: { + type: String, + enum: ["PENDING", "WON", "LOST", "VOID", "WITHDRAWN"],
Removed / Before Commit
- diff --git a/src/utils/multiBetExposure.js b/src/utils/multiBetExposure.js - index a557628..b2ca61c 100644 - : leg.leg_status; - - if (legStatus === "WON") { - const legProfit = confirmedAmount * leg.odds_matched; - confirmedAmount = confirmedAmount + legProfit; - } else if (["VOID", "WITHDRAWN"].includes(legStatus)) { - continue;
Added / After Commit
+ diff --git a/src/utils/multiBetExposure.js b/src/utils/multiBetExposure.js + index a557628..b2ca61c 100644 + : leg.leg_status; + + if (legStatus === "WON") { + const storedNetProfit = Number(leg.net_profit || 0); + const hasStoredProfit = Number(leg.gross_profit || 0) > 0 || + Number(leg.deduction_percent || 0) > 0 || + Number(leg.deduction_amount || 0) > 0; + const legProfit = hasStoredProfit + ? storedNetProfit + : confirmedAmount * leg.odds_matched; + confirmedAmount = confirmedAmount + legProfit; + } else if (["VOID", "WITHDRAWN"].includes(legStatus)) { + continue;