From 7cf37aace8b74cf801cf043e46544f93d451f9ab Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 20 Mar 2026 21:21:47 +0000 Subject: [PATCH] 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 --- app/routes/admin.sports-seasons.$id.simulate.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/routes/admin.sports-seasons.$id.simulate.tsx b/app/routes/admin.sports-seasons.$id.simulate.tsx index 0ccc474..6a37a2e 100644 --- a/app/routes/admin.sports-seasons.$id.simulate.tsx +++ b/app/routes/admin.sports-seasons.$id.simulate.tsx @@ -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(