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:
Claude 2026-03-20 21:21:47 +00:00
parent 063834d8e6
commit 7cf37aace8
No known key found for this signature in database

View file

@ -17,6 +17,7 @@ import { batchUpsertParticipantEvSnapshots } from "~/models/ev-snapshot";
import { findParticipantsBySportsSeasonId } from "~/models/participant";
import { getSimulator, type SimulatorType } from "~/services/simulations/registry";
import { calculateEV, type ScoringRules } from "~/services/ev-calculator";
import { recalculateAffectedLeagues } from "~/models/scoring-calculator";
// Default scoring rules — matches the season table defaults.
// 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)
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)
const today = new Date().toISOString().slice(0, 10); // YYYY-MM-DD
await batchUpsertParticipantEvSnapshots(