Skip to content

Conversation

@zacjones93
Copy link
Contributor

@zacjones93 zacjones93 commented Jan 22, 2026

Summary

  • Add competition_events table to store per-event submission windows for online competitions
  • Athletes can only submit scores within the configured window (submissionOpensAt/submissionClosesAt)
  • ISO 8601 datetime format for timezone-aware submission deadlines

Changes

  • Schema: Add competitionEventsTable with submissionOpensAt/submissionClosesAt fields
  • Migration: 0078_add-competition-events.sql
  • ID Generator: Add createCompetitionEventId to common.ts
  • Relations: Add competition ↔ events relation

Test plan

  • Run migration locally with pnpm db:migrate:dev
  • Verify table created with correct indexes
  • Type check passes

Next steps (not in this PR)

  • Server functions: CRUD for event submission windows
  • Organizer UI: Configure submission windows per event
  • Athlete validation: Check window before score submission

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

    • Added competition_events table with submissionOpensAt/submissionClosesAt and a unique competition+workout constraint; added createCompetitionEventId.
    • Organizer “Submission Windows” page and drag-and-drop manager; sidebar link shows only for online competitions.
    • Public workouts/schedule show window times and status; quick-action/status cards in organizer views.
    • Server CRUD for competition events and scoring enforcement for online submissions.
  • Migration

    • Apply 0079_add-competition-events.sql (pnpm db:migrate:dev).

Written for commit 80ebae5. Summary will update on new commits.

Summary by CodeRabbit

  • New Features
    • Introduced per-event submission window management for competitions. Organizers can now configure independent submission timelines (open and close times) for each event within a competition, enabling granular control over submission deadlines and improved flexibility in scheduling online competitive events with per-event settings.

✏️ Tip: You can customize this high-level summary in your review settings.

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>
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 22, 2026

Walkthrough

The 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

Cohort / File(s) Summary
ID Generator
apps/wodsmith-start/src/db/schemas/common.ts
Adds createCompetitionEventId() function with cevt_ prefix for generating competition event identifiers.
Schema Definitions
apps/wodsmith-start/src/db/schemas/competitions.ts
Introduces competitionEventsTable with fields for competition reference, workout reference, and submission window timestamps. Adds CompetitionEvent type and establishes bidirectional relations between competitions and competition events.
Database Migration & Metadata
apps/wodsmith-start/src/db/migrations/0079_add-competition-events.sql, apps/wodsmith-start/src/db/migrations/meta/_journal.json
Creates competition_events table with three indices (competition lookup, workout lookup, unique competition-workout composite). Updates migration journal with new entry (idx 79, tag 0079_add-competition-events).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A table for events, so shiny and new,
With indices sprinting and foreign keys true,
Competition events now have their own place,
Where submission windows can set the pace! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat(compete): add submission windows for online competitions (WOD-104)' directly and clearly describes the main change: adding submission windows for online competitions in the compete feature, which is precisely what the PR delivers.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link

🚀 Preview Deployed

URL: https://wodsmith-app-pr-202.zacjones93.workers.dev

Detail Value
Commit bd57ed8
Stage pr-202
Deployed 2026-01-22T05:03:29.772Z

This comment is automatically updated on each push to this PR.

Copy link

@cubic-dev-ai cubic-dev-ai bot left a 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
Copy link
Contributor

@coderabbitai coderabbitai bot left a 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.

Comment on lines 2 to 12
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
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 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 f

Repository: 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 sql

Repository: 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 2

Repository: 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.

Suggested change
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.

zacjones93 and others added 14 commits January 24, 2026 22:57
…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>
@zacjones93 zacjones93 merged commit c8150b4 into main Jan 25, 2026
16 of 17 checks passed
@zacjones93 zacjones93 deleted the zacjones93/wod-104-workout-submission-windows branch January 25, 2026 21:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants