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
?
67%
Quality Avg
?
69%
Security Avg
?
64%
Reviews
?
143
Review Result ?
solutionbowl/tenant-service · 5cd53f7d
This commit introduces a new function to calculate dead heat profit from net odds including deductions, along with integration of this logic into the horse racing multi-bet result calculations. It includes input validation and preserves consistent business logic. It also adds a new model field to track dead heat status. The implementation appears sensible and better encapsulated, with some minor style and validation improvements possible.
Quality
?
85%
Security
?
90%
Business Value
?
80%
Maintainability
?
83%
Issues & Suggested Fixes
?
1AI detects the issue
2Shows file, line, or evidence
3Suggests the fix to apply
Inconsistent Naming
Where
src/controllers/horseracing/result.controller.js:116
Issue / Evidence
inconsistent naming
Suggested Fix
rename 'deductionPercent' parameter to 'deductionPercent' from optional default 0 to always require a number to avoid implicit conversion
Unclear Formula Clarity
Where
src/controllers/horseracing/result.controller.js:121
Issue / Evidence
unclear formula clarity
Suggested Fix
add clarifying comments explaining the dead heat payout formula and multiplier to improve maintainability
Code Style
Where
src/controllers/horseracing/result.controller.js:1162-1167
Issue / Evidence
code style
Suggested Fix
break complex ternary/conditional expressions into if/else statements for clarity and debugging ease
Incomplete Description
Where
commit message
Issue / Evidence
incomplete description
Suggested Fix
expand commit message to explain the impact of dead heat calculation on multi bets to better inform reviewers and future maintainers
Code Change Preview · src/controllers/horseracing/result.controller.js
?
Removed / Before Commit
- diff --git a/src/controllers/horseracing/result.controller.js b/src/controllers/horseracing/result.controller.js - index b65a15e..c869d9e 100644 - return Number((Math.max(0, netProfitOdds) + 1).toFixed(4)); - }; - - const SPECIAL_FANCY_TYPES = new Set(["PHOTO", "OBJECTION", "ODDS_EVENS"]); - - const normalizeFancySettlementType = (type) => { - // 4. Get runner positions from HorseList - const horses = await HorseList.find({ race_id: raceId }).lean(); - const runnerPositions = {}; - - for (const horse of horses) { - if (horse.is_withdrawn) continue; - // Map both HorseList._id and horse._id (same) to position - runnerPositions[horse._id.toString()] = Number(horse.result); - } -
Added / After Commit
+ diff --git a/src/controllers/horseracing/result.controller.js b/src/controllers/horseracing/result.controller.js + index b65a15e..c869d9e 100644 + return Number((Math.max(0, netProfitOdds) + 1).toFixed(4)); + }; + + const calculateDeadHeatProfitFromNetOdds = ( + netOdds, + stake, + deductionPercent = 0, + ) => { + const numericNetOdds = Number(netOdds); + const numericStake = Number(stake); + const numericPercent = Number(deductionPercent || 0); + + if (!Number.isFinite(numericNetOdds) || numericNetOdds < 0) { + throw new Error("netOdds must be greater than or equal to 0"); + } +
Removed / Before Commit
- diff --git a/src/models/RacingBet.js b/src/models/RacingBet.js - index b9e6a17..55e1416 100644 - 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"],
Added / After Commit
+ diff --git a/src/models/RacingBet.js b/src/models/RacingBet.js + index b9e6a17..55e1416 100644 + deduction_percent: { type: Number, default: 0 }, + deduction_amount: { type: Number, default: 0 }, + net_profit: { type: Number, default: 0 }, + dead_heat: { type: Boolean, default: false }, + leg_status: { + type: String, + enum: ["PENDING", "WON", "LOST", "VOID", "WITHDRAWN"],