Address code review feedback on draft window implementation

- sports-data-sync: use unambiguous past placeholder dates for synced seasons,
  with a comment explaining the intent
- sports-season model: remove redundant top-level lte/gte imports (callback
  form already supplies them)
- _journal.json: add missing trailing newline
- sports-season test: mock ~/database/schema instead of stubbing all drizzle
  builder functions, matching the established pattern in the codebase
- admin list: compute today once in component body instead of per-row

https://claude.ai/code/session_01LHYgpyimF8v8odUB6kj8Qc
This commit is contained in:
Claude 2026-04-06 01:57:58 +00:00
parent 6dbda8465f
commit 7a9dd3b874
No known key found for this signature in database
5 changed files with 21 additions and 18 deletions

View file

@ -4,6 +4,19 @@ vi.mock("~/database/context", () => ({
database: vi.fn(),
}));
// Mock the schema so the schema module doesn't execute drizzle builder calls,
// following the same pattern as scoring-event-dashboard.test.ts.
vi.mock("~/database/schema", () => ({
sportsSeasons: {
id: "ss.id",
sportId: "ss.sport_id",
name: "ss.name",
year: "ss.year",
draftOn: "ss.draft_on",
draftOff: "ss.draft_off",
},
}));
vi.mock("drizzle-orm", () => ({
eq: (col: unknown, val: unknown) => ({ type: "eq", col, val }),
sql: (strings: TemplateStringsArray, ...values: unknown[]) => ({ type: "sql", strings, values }),
@ -12,19 +25,6 @@ vi.mock("drizzle-orm", () => ({
and: (...args: unknown[]) => ({ type: "and", args }),
desc: (col: unknown) => ({ type: "desc", col }),
asc: (col: unknown) => ({ type: "asc", col }),
relations: () => ({}),
pgTable: () => ({}),
pgEnum: (_name: string, values: string[]) => values,
boolean: () => ({ notNull: () => ({ default: () => ({}) }) }),
integer: () => ({ notNull: () => ({}), default: () => ({}) }),
varchar: () => ({ notNull: () => ({}) }),
uuid: () => ({ primaryKey: () => ({}), notNull: () => ({ references: () => ({}) }) }),
timestamp: () => ({ defaultNow: () => ({ notNull: () => ({}) }) }),
decimal: () => ({ notNull: () => ({ default: () => ({}) }), precision: () => ({}) }),
date: () => ({ notNull: () => ({}) }),
text: () => ({}),
index: () => ({}),
uniqueIndex: () => ({}),
}));
import { findAllSportsSeasons, findDraftableSportsSeasons } from "../sports-season";

View file

@ -1,4 +1,4 @@
import { eq, sql, lte, gte } from "drizzle-orm";
import { eq, sql } from "drizzle-orm";
import { database } from "~/database/context";
import * as schema from "~/database/schema";

View file

@ -40,6 +40,7 @@ export async function loader() {
export default function AdminSportsSeasons({ loaderData }: Route.ComponentProps) {
const { sportsSeasons } = loaderData;
const today = new Date().toISOString().slice(0, 10);
return (
<div className="p-8">
@ -115,7 +116,6 @@ export default function AdminSportsSeasons({ loaderData }: Route.ComponentProps)
</TableCell>
<TableCell>
{(() => {
const today = new Date().toISOString().slice(0, 10);
const active = season.draftOn <= today && today <= season.draftOff;
return (
<div className="space-y-0.5">

View file

@ -336,8 +336,11 @@ export async function importSportsDataFromJSON(
| "playoffs"
| "regular_season"
| "majors",
draftOn: "2099-12-31",
draftOff: "2099-12-31",
// Placeholder: season is not draftable until an admin sets real dates.
// A narrow past window is used so the season never accidentally appears
// in league creation without an intentional update.
draftOn: "2000-01-01",
draftOff: "2000-01-02",
})
.returning();
sportsSeasonIdMap.set(seasonKey, created_.id);

View file

@ -493,4 +493,4 @@
"breakpoints": true
}
]
}
}