-
Notifications
You must be signed in to change notification settings - Fork 1
feat(compete): add submission windows for online competitions (WOD-104) #202
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(compete): add submission windows for online competitions (WOD-104) #202
Conversation
Add per-event submission window support for online competitions. Athletes can only submit scores within the configured window. - Add competitionEventsTable with submissionOpensAt/submissionClosesAt - Add createCompetitionEventId generator - Add migration 0078 WOD-104 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
WalkthroughThe changes introduce a new Competition Events feature to the database schema, including a dedicated table for storing per-event settings for competitions. This includes an ID generator function, TypeScript schema definitions with types and relations, a SQL migration to create the table with appropriate indices, and a migration journal entry. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🚀 Preview DeployedURL: https://wodsmith-app-pr-202.zacjones93.workers.dev
This comment is automatically updated on each push to this PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No issues found across 3 files
Create a new `competition_events` table to manage submission windows for online competitions. This includes fields for event timing and foreign key relationships to existing competition data. Additionally, create necessary indexes for efficient querying. Closes WOD-104
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@apps/wodsmith-start/src/db/migrations/0079_add-competition-events.sql`:
- Around line 2-12: The migration's competition_events table is missing a
foreign key for track_workout_id; add a FOREIGN KEY constraint on
track_workout_id referencing track_workout(id) with the same referential actions
as others (ON UPDATE no action ON DELETE no action). Update the CREATE TABLE
`competition_events` statement (or add an ALTER TABLE if modifying an existing
migration) to include the FOREIGN KEY (`track_workout_id`) REFERENCES
`track_workout`(`id`) ON UPDATE no action ON DELETE no action so referential
integrity matches the rest of the schema.
| CREATE TABLE `competition_events` ( | ||
| `id` text PRIMARY KEY NOT NULL, | ||
| `created_at` integer NOT NULL, | ||
| `updated_at` integer NOT NULL, | ||
| `update_counter` integer DEFAULT 0, | ||
| `competition_id` text NOT NULL, | ||
| `track_workout_id` text NOT NULL, | ||
| `submission_opens_at` text, | ||
| `submission_closes_at` text, | ||
| FOREIGN KEY (`competition_id`) REFERENCES `competitions`(`id`) ON UPDATE no action ON DELETE cascade | ||
| ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Find the migration file and examine its full content
find apps/wodsmith-start/src/db/migrations -name "*add-competition-events*" -type fRepository: wodsmith/thewodapp
Length of output: 131
🏁 Script executed:
#!/bin/bash
# Search for track_workouts or workout-related table definitions
rg -n "CREATE TABLE.*[Ww]orkout" apps/wodsmith-start/src/db/migrations/ -A 15 --type sqlRepository: wodsmith/thewodapp
Length of output: 22610
🏁 Script executed:
#!/bin/bash
# Check if there are any existing foreign key patterns for track_workout_id in other migration files
rg -n "track_workout_id" apps/wodsmith-start/src/db/migrations/ --type sql -B 2 -A 2Repository: wodsmith/thewodapp
Length of output: 1312
Add foreign key constraint on track_workout_id.
The track_workout_id column lacks a foreign key constraint to ensure referential integrity. All other similar FKs in the codebase reference the track_workout table with ON DELETE no action.
Fix
`track_workout_id` text NOT NULL,
`submission_opens_at` text,
`submission_closes_at` text,
- FOREIGN KEY (`competition_id`) REFERENCES `competitions`(`id`) ON UPDATE no action ON DELETE cascade
+ FOREIGN KEY (`competition_id`) REFERENCES `competitions`(`id`) ON UPDATE no action ON DELETE cascade,
+ FOREIGN KEY (`track_workout_id`) REFERENCES `track_workout`(`id`) ON UPDATE no action ON DELETE no action
);📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| CREATE TABLE `competition_events` ( | |
| `id` text PRIMARY KEY NOT NULL, | |
| `created_at` integer NOT NULL, | |
| `updated_at` integer NOT NULL, | |
| `update_counter` integer DEFAULT 0, | |
| `competition_id` text NOT NULL, | |
| `track_workout_id` text NOT NULL, | |
| `submission_opens_at` text, | |
| `submission_closes_at` text, | |
| FOREIGN KEY (`competition_id`) REFERENCES `competitions`(`id`) ON UPDATE no action ON DELETE cascade | |
| ); | |
| CREATE TABLE `competition_events` ( | |
| `id` text PRIMARY KEY NOT NULL, | |
| `created_at` integer NOT NULL, | |
| `updated_at` integer NOT NULL, | |
| `update_counter` integer DEFAULT 0, | |
| `competition_id` text NOT NULL, | |
| `track_workout_id` text NOT NULL, | |
| `submission_opens_at` text, | |
| `submission_closes_at` text, | |
| FOREIGN KEY (`competition_id`) REFERENCES `competitions`(`id`) ON UPDATE no action ON DELETE cascade, | |
| FOREIGN KEY (`track_workout_id`) REFERENCES `track_workout`(`id`) ON UPDATE no action ON DELETE no action | |
| ); |
🤖 Prompt for AI Agents
In `@apps/wodsmith-start/src/db/migrations/0079_add-competition-events.sql` around
lines 2 - 12, The migration's competition_events table is missing a foreign key
for track_workout_id; add a FOREIGN KEY constraint on track_workout_id
referencing track_workout(id) with the same referential actions as others (ON
UPDATE no action ON DELETE no action). Update the CREATE TABLE
`competition_events` statement (or add an ALTER TABLE if modifying an existing
migration) to include the FOREIGN KEY (`track_workout_id`) REFERENCES
`track_workout`(`id`) ON UPDATE no action ON DELETE no action so referential
integrity matches the rest of the schema.
…nline competitions - Add competition_events migration for per-event submission window settings - Add competition-event-fns server functions for CRUD operations - Add submission windows manager component with drag-and-drop workout assignment - Add submission windows page for organizers - Add public submission windows display component - Add Zustand state for submission windows management - Add tests for competition event server functions Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Use Date.UTC() instead of new Date(dateStr) to create timezone-independent timestamps, preventing browser local timezone from interfering with the competition timezone conversion. Previously, typing "2" for hour would display "9" due to the offset being applied twice - once by JS Date parsing and once by the explicit conversion. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Hide Schedule menu item for online competitions (use submission windows instead) - Hide Submission Windows menu item for in-person competitions - Hide Published Assignments and Rotations sections on volunteers page for online competitions (different volunteer workflow for online events) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…e scoring - Add isWithinSubmissionWindow check for online competition score submissions - Pass competitionType to sidebar in organizer layout - Add submission-windows to route labels for breadcrumb Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…ts page - Add submission window times to workout cards for online competitions - Show open/closed/upcoming status with visual indicators - Fetch competition events data for public workouts page Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Accept main's workout card navigation (eventId, slug, Link) and remove incomplete submission window display from public pages. Core submission window infrastructure remains intact. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Fix competition-event-fns.test.ts: mock uses inputValidator (not validator) to match actual TanStack Start API used in codebase - Fix competition-score-fns.test.ts: add withSubmissionWindowCheck flag to handle different query ordering when isWithinSubmissionWindow is called - Add competition and competitionEvent mock config options for submission window testing Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Keep CompetitionTabs from main for in-person schedule UI - Keep PublicSubmissionWindows and submission window fields from feature branch - Merge useLoaderData to include competition from parent route Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Summary
competition_eventstable to store per-event submission windows for online competitionsChanges
competitionEventsTablewithsubmissionOpensAt/submissionClosesAtfields0078_add-competition-events.sqlcreateCompetitionEventIdto common.tsTest plan
pnpm db:migrate:devNext steps (not in this PR)
Closes WOD-104
🤖 Generated with Claude Code
Summary by cubic
Adds per-event submission windows for online competitions, with organizer tools to assign workouts and set open/close times, public visibility, and enforcement that blocks out-of-window score submissions (WOD-104).
New Features
Migration
Written for commit 80ebae5. Summary will update on new commits.
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.