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 <noreply@anthropic.com>
This commit is contained in:
Chris Parsons 2026-05-01 15:14:49 +00:00
parent fd99cab61b
commit 0dc962135c
No known key found for this signature in database
9 changed files with 31 additions and 31 deletions

View file

@ -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).

View file

@ -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";

View file

@ -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" };

View file

@ -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: {

View file

@ -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: {

View file

@ -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

View file

@ -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);

View file

@ -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]));

View file

@ -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),
}),
]);