From 0dc962135c7edadd9ce32e61800bea37b9c063a9 Mon Sep 17 00:00:00 2001 From: Chris Parsons Date: Fri, 1 May 2026 15:14:49 +0000 Subject: [PATCH] refactor(routes): update route layer to use renamed schema exports - Update model import from ~/models/participant to ~/models/season-participant - Rename schema.participants to schema.seasonParticipants - Rename schema.participantResults to schema.seasonParticipantResults - Rename db.query.participants to db.query.seasonParticipants - Update 9 route files and 1 test file Affected files: - admin.sports-seasons.$id.events.$eventId.bracket.server.ts - admin.sports-seasons.$id.participants.tsx - api/draft.force-manual-pick.ts - api/draft.make-pick.ts - api/draft.replace-pick.ts - api/seasons.$seasonId.draft.ts - leagues/$leagueId.draft-board.$seasonId.tsx - leagues/$leagueId.sports-seasons.$sportsSeasonId.server.ts - admin/__tests__/sports-seasons-participants.test.ts Error count reduced from 499 to 453 (46 errors fixed). Co-Authored-By: Claude Opus 4.7 --- ...sons.$id.events.$eventId.bracket.server.ts | 4 ++-- .../admin.sports-seasons.$id.participants.tsx | 2 +- .../sports-seasons-participants.test.ts | 4 ++-- app/routes/api/draft.force-manual-pick.ts | 4 ++-- app/routes/api/draft.make-pick.ts | 4 ++-- app/routes/api/draft.replace-pick.ts | 8 ++++---- app/routes/api/seasons.$seasonId.draft.ts | 6 +++--- .../$leagueId.draft-board.$seasonId.tsx | 20 +++++++++---------- ...d.sports-seasons.$sportsSeasonId.server.ts | 10 +++++----- 9 files changed, 31 insertions(+), 31 deletions(-) diff --git a/app/routes/admin.sports-seasons.$id.events.$eventId.bracket.server.ts b/app/routes/admin.sports-seasons.$id.events.$eventId.bracket.server.ts index 65f7cd1..3bb6044 100644 --- a/app/routes/admin.sports-seasons.$id.events.$eventId.bracket.server.ts +++ b/app/routes/admin.sports-seasons.$id.events.$eventId.bracket.server.ts @@ -595,9 +595,9 @@ export async function action({ request, params }: Route.ActionArgs) { // the "never un-finalize" guard in upsertParticipantResult. const db = database(); await db - .delete(schema.participantResults) + .delete(schema.seasonParticipantResults) .where( - eq(schema.participantResults.sportsSeasonId, event.sportsSeasonId) + eq(schema.seasonParticipantResults.sportsSeasonId, event.sportsSeasonId) ); // Replay each completed match in bracket order (earlier rounds first). diff --git a/app/routes/admin.sports-seasons.$id.participants.tsx b/app/routes/admin.sports-seasons.$id.participants.tsx index b2d4cb1..64e5da3 100644 --- a/app/routes/admin.sports-seasons.$id.participants.tsx +++ b/app/routes/admin.sports-seasons.$id.participants.tsx @@ -10,7 +10,7 @@ import { createParticipant, deleteParticipant, updateParticipant, -} from "~/models/participant"; +} from "~/models/season-participant"; import { Button } from "~/components/ui/button"; import { Input } from "~/components/ui/input"; import { Label } from "~/components/ui/label"; diff --git a/app/routes/admin/__tests__/sports-seasons-participants.test.ts b/app/routes/admin/__tests__/sports-seasons-participants.test.ts index ebcb843..adc7d97 100644 --- a/app/routes/admin/__tests__/sports-seasons-participants.test.ts +++ b/app/routes/admin/__tests__/sports-seasons-participants.test.ts @@ -1,6 +1,6 @@ import { describe, it, expect, vi, beforeEach } from "vitest"; -vi.mock("~/models/participant", () => ({ +vi.mock("~/models/season-participant", () => ({ findParticipantsBySportsSeasonId: vi.fn(), findParticipantByName: vi.fn(), createParticipant: vi.fn(), @@ -19,7 +19,7 @@ vi.mock("~/lib/logger", () => ({ import { findParticipantByName, updateParticipant, -} from "~/models/participant"; +} from "~/models/season-participant"; import { action } from "~/routes/admin.sports-seasons.$id.participants"; const mockParams = { id: "season-1" }; diff --git a/app/routes/api/draft.force-manual-pick.ts b/app/routes/api/draft.force-manual-pick.ts index bbb1d53..8d58657 100644 --- a/app/routes/api/draft.force-manual-pick.ts +++ b/app/routes/api/draft.force-manual-pick.ts @@ -87,8 +87,8 @@ export async function action(args: ActionFunctionArgs) { } // Get participant details - const participant = await db.query.participants.findFirst({ - where: eq(schema.participants.id, participantId), + const participant = await db.query.seasonParticipants.findFirst({ + where: eq(schema.seasonParticipants.id, participantId), with: { sportsSeason: { with: { diff --git a/app/routes/api/draft.make-pick.ts b/app/routes/api/draft.make-pick.ts index d3fb4e7..3070e61 100644 --- a/app/routes/api/draft.make-pick.ts +++ b/app/routes/api/draft.make-pick.ts @@ -96,8 +96,8 @@ export async function action(args: ActionFunctionArgs) { } // Get participant details - const participant = await db.query.participants.findFirst({ - where: eq(schema.participants.id, participantId), + const participant = await db.query.seasonParticipants.findFirst({ + where: eq(schema.seasonParticipants.id, participantId), with: { sportsSeason: { with: { diff --git a/app/routes/api/draft.replace-pick.ts b/app/routes/api/draft.replace-pick.ts index 38b415f..2fa2b42 100644 --- a/app/routes/api/draft.replace-pick.ts +++ b/app/routes/api/draft.replace-pick.ts @@ -78,8 +78,8 @@ export async function action(args: ActionFunctionArgs) { } } - const participant = await db.query.participants.findFirst({ - where: eq(schema.participants.id, participantId), + const participant = await db.query.seasonParticipants.findFirst({ + where: eq(schema.seasonParticipants.id, participantId), with: { sportsSeason: { with: { sport: true } }, }, @@ -128,8 +128,8 @@ export async function action(args: ActionFunctionArgs) { } // Fetch old participant name for the audit log (before overwriting the pick) - const oldParticipant = await db.query.participants.findFirst({ - where: eq(schema.participants.id, oldParticipantId), + const oldParticipant = await db.query.seasonParticipants.findFirst({ + where: eq(schema.seasonParticipants.id, oldParticipantId), }); // Update the pick in-place diff --git a/app/routes/api/seasons.$seasonId.draft.ts b/app/routes/api/seasons.$seasonId.draft.ts index 0d86a8d..57e233a 100644 --- a/app/routes/api/seasons.$seasonId.draft.ts +++ b/app/routes/api/seasons.$seasonId.draft.ts @@ -51,13 +51,13 @@ export async function loader({ params }: LoaderFunctionArgs) { round: schema.draftPicks.round, teamName: schema.teams.name, teamOwnerId: schema.teams.ownerId, - participantName: schema.participants.name, + participantName: schema.seasonParticipants.name, sport: schema.sports.name, }) .from(schema.draftPicks) .innerJoin(schema.teams, eq(schema.draftPicks.teamId, schema.teams.id)) - .innerJoin(schema.participants, eq(schema.draftPicks.participantId, schema.participants.id)) - .innerJoin(schema.sportsSeasons, eq(schema.participants.sportsSeasonId, schema.sportsSeasons.id)) + .innerJoin(schema.seasonParticipants, eq(schema.draftPicks.participantId, schema.seasonParticipants.id)) + .innerJoin(schema.sportsSeasons, eq(schema.seasonParticipants.sportsSeasonId, schema.sportsSeasons.id)) .innerJoin(schema.sports, eq(schema.sportsSeasons.sportId, schema.sports.id)) .where(eq(schema.draftPicks.seasonId, seasonId)) .orderBy(schema.draftPicks.pickNumber); diff --git a/app/routes/leagues/$leagueId.draft-board.$seasonId.tsx b/app/routes/leagues/$leagueId.draft-board.$seasonId.tsx index 094a1b0..2ddeba7 100644 --- a/app/routes/leagues/$leagueId.draft-board.$seasonId.tsx +++ b/app/routes/leagues/$leagueId.draft-board.$seasonId.tsx @@ -76,19 +76,19 @@ export async function loader(args: Route.LoaderArgs) { round: schema.draftPicks.round, pickInRound: schema.draftPicks.pickInRound, team: schema.teams, - participant: schema.participants, + participant: schema.seasonParticipants, sport: schema.sports, scoringPattern: schema.sportsSeasons.scoringPattern, }) .from(schema.draftPicks) .innerJoin(schema.teams, eq(schema.draftPicks.teamId, schema.teams.id)) .innerJoin( - schema.participants, - eq(schema.draftPicks.participantId, schema.participants.id) + schema.seasonParticipants, + eq(schema.draftPicks.participantId, schema.seasonParticipants.id) ) .innerJoin( schema.sportsSeasons, - eq(schema.participants.sportsSeasonId, schema.sportsSeasons.id) + eq(schema.seasonParticipants.sportsSeasonId, schema.sportsSeasons.id) ) .innerJoin(schema.sports, eq(schema.sportsSeasons.sportId, schema.sports.id)) .where(eq(schema.draftPicks.seasonId, seasonId)) @@ -104,13 +104,13 @@ export async function loader(args: Route.LoaderArgs) { const results = await db .select({ - participantId: schema.participantResults.participantId, - sportsSeasonId: schema.participantResults.sportsSeasonId, - finalPosition: schema.participantResults.finalPosition, - isPartialScore: schema.participantResults.isPartialScore, + participantId: schema.seasonParticipantResults.participantId, + sportsSeasonId: schema.seasonParticipantResults.sportsSeasonId, + finalPosition: schema.seasonParticipantResults.finalPosition, + isPartialScore: schema.seasonParticipantResults.isPartialScore, }) - .from(schema.participantResults) - .where(inArray(schema.participantResults.participantId, participantIds)); + .from(schema.seasonParticipantResults) + .where(inArray(schema.seasonParticipantResults.participantId, participantIds)); const resultByParticipant = new Map(results.map((r) => [r.participantId, r])); diff --git a/app/routes/leagues/$leagueId.sports-seasons.$sportsSeasonId.server.ts b/app/routes/leagues/$leagueId.sports-seasons.$sportsSeasonId.server.ts index 0ff93e7..4af7fbc 100644 --- a/app/routes/leagues/$leagueId.sports-seasons.$sportsSeasonId.server.ts +++ b/app/routes/leagues/$leagueId.sports-seasons.$sportsSeasonId.server.ts @@ -233,15 +233,15 @@ export async function loader(args: Route.LoaderArgs) { // Fetch group-stage losers and all participant results for bracket scoring const [eliminatedResults, allResults] = await Promise.all([ - db.query.participantResults.findMany({ + db.query.seasonParticipantResults.findMany({ where: and( - eq(schema.participantResults.sportsSeasonId, sportsSeasonId), - eq(schema.participantResults.finalPosition, 0) + eq(schema.seasonParticipantResults.sportsSeasonId, sportsSeasonId), + eq(schema.seasonParticipantResults.finalPosition, 0) ), with: { participant: true }, }), - db.query.participantResults.findMany({ - where: eq(schema.participantResults.sportsSeasonId, sportsSeasonId), + db.query.seasonParticipantResults.findMany({ + where: eq(schema.seasonParticipantResults.sportsSeasonId, sportsSeasonId), }), ]);