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 · df15ba95
The commit refines the handling of bet leg statuses by consistently excluding 'VOID' and 'WITHDRAWN' statuses in filtering operations and defining enumeration values. This improves the clarity and correctness of multi-bet state management, thus enhancing business logic integrity and reducing potential bugs from improper state handling. However, the commit message is vague, and code comments or documentation updates are absent, which could improve maintainability.
Quality
?
75%
Security
?
80%
Business Value
?
70%
Maintainability
?
73%
Issues & Suggested Fixes
?
1AI detects the issue
2Shows file, line, or evidence
3Suggests the fix to apply
Vague
Where
commit message
Issue / Evidence
vague
Suggested Fix
use a descriptive commit message explaining the purpose and impact of changes
Lack Of Comments Explaining Filtering Logi...
Where
src/controllers/multiBet.controller.js:379
Issue / Evidence
lack of comments explaining filtering logic
Suggested Fix
add comments to clarify the purpose of filtering out 'VOID' and 'WITHDRAWN' legs
Enum Definition Lacks Explanatory Comments
Where
src/models/RacingBet.js:19
Issue / Evidence
enum definition lacks explanatory comments
Suggested Fix
document the meaning of each enum value to aid maintainability
Magic Strings For Statuses
Where
src/utils/multiBetExposure.js:41
Issue / Evidence
magic strings for statuses
Suggested Fix
consider defining constants or enums for statuses to avoid typos and improve readability
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 a87cb25..22001d8 100644 - - if (bet.bet_status === "ACCEPTED") { - // Check leg statuses to determine actual status - const allWon = legs.every(leg => leg.leg_status === "WON"); - const anyLost = legs.some(leg => leg.leg_status === "LOST"); - const allPending = legs.every(leg => leg.leg_status === "PENDING"); - - if (anyLost) { - dynamicBetStatus = "LOSS"; - dynamicBetStatus = "WON"; - } else if (allPending) { - dynamicBetStatus = "PENDING"; - } else { - // Mixed (some won, some pending) - dynamicBetStatus = "IN_PROGRESS";
Added / After Commit
+ diff --git a/src/controllers/multiBet.controller.js b/src/controllers/multiBet.controller.js + index a87cb25..22001d8 100644 + + if (bet.bet_status === "ACCEPTED") { + // Check leg statuses to determine actual status + const activeLegs = legs.filter(leg => !["VOID", "WITHDRAWN"].includes(String(leg.leg_status || ""))); + const allWon = activeLegs.length > 0 && activeLegs.every(leg => leg.leg_status === "WON"); + const anyLost = activeLegs.some(leg => leg.leg_status === "LOST"); + const allPending = activeLegs.length > 0 && activeLegs.every(leg => leg.leg_status === "PENDING"); + + if (anyLost) { + dynamicBetStatus = "LOSS"; + dynamicBetStatus = "WON"; + } else if (allPending) { + dynamicBetStatus = "PENDING"; + } else if (!activeLegs.length) { + dynamicBetStatus = "VOID"; + } else {
Removed / Before Commit
- diff --git a/src/models/RacingBet.js b/src/models/RacingBet.js - index 7ddc6e1..d049332 100644 - position: { type: Number, default: 1 }, - leg_status: { - type: String, - enum: ["PENDING", "WON", "LOST", "VOID"], - default: "PENDING" - } - }, { timestamps: true });
Added / After Commit
+ diff --git a/src/models/RacingBet.js b/src/models/RacingBet.js + index 7ddc6e1..d049332 100644 + position: { type: Number, default: 1 }, + leg_status: { + type: String, + enum: ["PENDING", "WON", "LOST", "VOID", "WITHDRAWN"], + default: "PENDING" + } + }, { timestamps: true });
Removed / Before Commit
- diff --git a/src/utils/multiBetExposure.js b/src/utils/multiBetExposure.js - index b2dbbf3..a557628 100644 - if (legStatus === "WON") { - const legProfit = confirmedAmount * leg.odds_matched; - confirmedAmount = confirmedAmount + legProfit; - } else if (legStatus === "LOST") { - // If any leg lost, no exposures - return; - } - - const activeLegPosition = Number(activeLeg.position || activeLeg.leg_number || 1); - const maxPosition = sortedLegs.reduce((max, leg) => { - const position = Number(leg.position || leg.leg_number || 1); - return Math.max(max, position); - }, 0);
Added / After Commit
+ diff --git a/src/utils/multiBetExposure.js b/src/utils/multiBetExposure.js + index b2dbbf3..a557628 100644 + if (legStatus === "WON") { + const legProfit = confirmedAmount * leg.odds_matched; + confirmedAmount = confirmedAmount + legProfit; + } else if (["VOID", "WITHDRAWN"].includes(legStatus)) { + continue; + } else if (legStatus === "LOST") { + // If any leg lost, no exposures + return; + } + + const activeLegPosition = Number(activeLeg.position || activeLeg.leg_number || 1); + const maxPosition = sortedLegs + .filter((leg) => !["VOID", "WITHDRAWN"].includes(String(leg.leg_status || ""))) + .reduce((max, leg) => { + const position = Number(leg.position || leg.leg_number || 1); + return Math.max(max, position);