Polish simulate route after code review
- Remove redundant db variable; use database() inline consistent with all other model calls in this file - Parallelize standings recalculation with Promise.all - Update file header comment to include the standings refresh step https://claude.ai/code/session_01S9Pk4wTSphANMhPWaURPTn
This commit is contained in:
parent
e284d08f2b
commit
b21c553c9c
1 changed files with 5 additions and 7 deletions
|
|
@ -5,8 +5,9 @@
|
|||
* 1. Guards against concurrent runs via simulationStatus
|
||||
* 2. Runs the appropriate simulator based on the sport's simulatorType
|
||||
* 3. Persists updated EVs to participantExpectedValues (transactional)
|
||||
* 4. Takes an EV snapshot from simulation output (upsert for today's date)
|
||||
* 5. Redirects back to the sports season admin page
|
||||
* 4. Refreshes cached projectedPoints in teamStandings for all affected fantasy seasons
|
||||
* 5. Takes an EV snapshot from simulation output (upsert for today's date)
|
||||
* 6. Redirects back to the sports season admin page
|
||||
*/
|
||||
|
||||
import { redirect } from "react-router";
|
||||
|
|
@ -104,13 +105,10 @@ export async function action({ params }: Route.ActionArgs) {
|
|||
await batchUpsertParticipantEVs(evInputs);
|
||||
|
||||
// Refresh cached projectedPoints in teamStandings for all affected fantasy seasons
|
||||
const db = database();
|
||||
const seasonSports = await db.query.seasonSports.findMany({
|
||||
const seasonSports = await database().query.seasonSports.findMany({
|
||||
where: eq(schema.seasonSports.sportsSeasonId, sportsSeasonId),
|
||||
});
|
||||
for (const { seasonId } of seasonSports) {
|
||||
await recalculateStandings(seasonId, db);
|
||||
}
|
||||
await Promise.all(seasonSports.map(({ seasonId }) => recalculateStandings(seasonId)));
|
||||
|
||||
// Take EV snapshot from simulation output (not re-read from DB)
|
||||
const today = new Date().toISOString().slice(0, 10); // YYYY-MM-DD
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue