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 · a2062b1b
The commit adds win deduction logic for back and lay bets and introduces settlement logic for fancy markets with deductions. It uses parallel fetching and batch updates which improves performance. There is validation for inputs and defensive checks, but some areas could improve in clarity and robustness, especially around type conversions and error handling. The security score is moderate due to minimal input validation and no explicit authorization checks visible in the diff.
Quality
?
85%
Security
?
60%
Business Value
?
80%
Maintainability
?
83%
Issues & Suggested Fixes
?
1AI detects the issue
2Shows file, line, or evidence
3Suggests the fix to apply
Error Handling
Where
src/controllers/horseracing/result.controller.js:131
Issue / Evidence
error handling
Suggested Fix
add logging or better error management when tote odds are missing to aid debugging
Missing Validation
Where
src/controllers/horseracing/result.controller.js:201
Issue / Evidence
validation
Suggested Fix
add explicit validation for marketOddstype values beyond upper casing and defaulting to 'INDIAMANUAL'
Input Hygiene
Where
src/controllers/horseracing/result.controller.js:308
Issue / Evidence
input hygiene
Suggested Fix
validate and sanitize 'marketType' string input to avoid potential injection or logic errors
Robustness
Where
src/controllers/horseracing/result.controller.js:369
Issue / Evidence
robustness
Suggested Fix
check racingBet existence with detailed error or warning rather than a silent continue to improve debugging
Clarity
Where
src/controllers/horseracing/result.controller.js:200-208
Issue / Evidence
clarity
Suggested Fix
restructure refundAmount calculation for lay bets for easier readability
Descriptiveness
Where
commit message
Issue / Evidence
descriptiveness
Suggested Fix
improve commit message to clearly describe what the win deduction on back and lay with fancy changes do
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 59d2b96..306b812 100644 - const Wallet = require("../../models/Wallet"); - const Ledger = require("../../models/Ledger"); - - - exports.settleMarket = async (req, res) => { - try { - const { eventId } = req.params; - - const eventObjectId = new mongoose.Types.ObjectId(eventId); - - // 1. Get finalized positions for all runners (lean = no Mongoose overhead) - const horses = await HorseList.find({ race_id: eventId }).lean(); - if (!horses || horses.length === 0) { - return res.status(404).json({ status: false, message: "No runners found for this race" }); - } -
Added / After Commit
+ diff --git a/src/controllers/horseracing/result.controller.js b/src/controllers/horseracing/result.controller.js + index 59d2b96..306b812 100644 + const Wallet = require("../../models/Wallet"); + const Ledger = require("../../models/Ledger"); + + exports.settleMarket = async (req, res) => { + try { + const { eventId } = req.params; + + const eventObjectId = new mongoose.Types.ObjectId(eventId); + + // 1. Get finalized positions + tote odds for all runners + const horses = await HorseList.find({ race_id: eventId }).lean(); + if (!horses || horses.length === 0) { + return res.status(404).json({ status: false, message: "No runners found for this race" }); + } + + const runnerPositions = {};
Removed / Before Commit
- diff --git a/src/controllers/horseracing/test.controller.js b/src/controllers/horseracing/test.controller.js - index f05c28c..04defab 100644 - return res.status(500).json({ error: error.message }); - } - };
Added / After Commit
+ diff --git a/src/controllers/horseracing/test.controller.js b/src/controllers/horseracing/test.controller.js + index f05c28c..04defab 100644 + return res.status(500).json({ error: error.message }); + } + }; + + + + + exports.settleMarket = async (req, res) => { + try { + const { eventId } = req.params; + const { win_deduction, places_deduction, fancy_deduction } = req.body; + + if (!mongoose.Types.ObjectId.isValid(eventId)) { + return res.status(400).json({ status: false, message: "Invalid Event/Race ID" }); + } +