Force standings recalculation after EV simulation
After persisting updated EVs to participantExpectedValues, call recalculateAffectedLeagues so that teamStandings.projectedPoints (and all related standing fields) immediately reflect the new EV rather than remaining stale until the next scoring event. https://claude.ai/code/session_01S9Pk4wTSphANMhPWaURPTn
This commit is contained in:
parent
063834d8e6
commit
7cf37aace8
1 changed files with 4 additions and 0 deletions
|
|
@ -17,6 +17,7 @@ import { batchUpsertParticipantEvSnapshots } from "~/models/ev-snapshot";
|
||||||
import { findParticipantsBySportsSeasonId } from "~/models/participant";
|
import { findParticipantsBySportsSeasonId } from "~/models/participant";
|
||||||
import { getSimulator, type SimulatorType } from "~/services/simulations/registry";
|
import { getSimulator, type SimulatorType } from "~/services/simulations/registry";
|
||||||
import { calculateEV, type ScoringRules } from "~/services/ev-calculator";
|
import { calculateEV, type ScoringRules } from "~/services/ev-calculator";
|
||||||
|
import { recalculateAffectedLeagues } from "~/models/scoring-calculator";
|
||||||
|
|
||||||
// Default scoring rules — matches the season table defaults.
|
// Default scoring rules — matches the season table defaults.
|
||||||
// Per-league EV is recalculated from probabilities using league-specific rules in standings.
|
// Per-league EV is recalculated from probabilities using league-specific rules in standings.
|
||||||
|
|
@ -99,6 +100,9 @@ export async function action({ params }: Route.ActionArgs) {
|
||||||
// Persist updated EVs (transactional)
|
// Persist updated EVs (transactional)
|
||||||
await batchUpsertParticipantEVs(evInputs);
|
await batchUpsertParticipantEVs(evInputs);
|
||||||
|
|
||||||
|
// Force standings recalculation so projectedPoints reflects the new EV
|
||||||
|
await recalculateAffectedLeagues(sportsSeasonId);
|
||||||
|
|
||||||
// Take EV snapshot from simulation output (not re-read from DB)
|
// Take EV snapshot from simulation output (not re-read from DB)
|
||||||
const today = new Date().toISOString().slice(0, 10); // YYYY-MM-DD
|
const today = new Date().toISOString().slice(0, 10); // YYYY-MM-DD
|
||||||
await batchUpsertParticipantEvSnapshots(
|
await batchUpsertParticipantEvSnapshots(
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue