Skip to content

feat(phases): add override + set_ratings table#146

Merged
chiptus merged 5 commits into
mainfrom
claude/issue-139-phase-override-migration
Jul 10, 2026
Merged

feat(phases): add override + set_ratings table#146
chiptus merged 5 commits into
mainfrom
claude/issue-139-phase-override-migration

Conversation

@chiptus

@chiptus chiptus commented Jul 10, 2026

Copy link
Copy Markdown
Owner

Adds the epic's one migration — nullable phase_override on the edition plus set_ratings (RLS mirroring votes) — and the getEffectiveFestivalPhase seam (override ?? derived), with a Core Team admin control to set/clear the override. Per #139.

Note: this PR does not by itself change how the edition's default-tab redirect picks a phase (that logic lives in #137's branch). Once both #137 and #139 are merged, src/routes/festivals/$festivalSlug/editions/$editionSlug.tsx's beforeLoad should be updated to call getEffectiveFestivalPhase instead of getFestivalPhase so an admin override also affects the landing tab, not just the banner/label — flagging this as a small follow-up once both land.

Verification

  • In the edition admin area, set a phase override (e.g. force "live") and confirm useFestivalPhase()-driven UI (banner/label) reflects it immediately.
  • Clear the override and confirm the edition falls back to its derived phase.
  • Run pnpm test src/lib/festivalPhase.test.ts — override-wins-over-every-derived-case and null-falls-through-to-derived cases pass.
  • Insert two set_ratings rows for the same (user_id, set_id) as different users — both succeed; as the same user — second insert violates the unique constraint.
  • Confirm no supabase db push/db reset was run; migration is timestamp-prefixed under supabase/migrations/.

Closes #139.


Generated by Claude Code

Copilot AI review requested due to automatic review settings July 10, 2026 13:13
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@vercel

vercel Bot commented Jul 10, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
upline Ready Ready Preview, Comment Jul 10, 2026 3:39pm

@github-actions

github-actions Bot commented Jul 10, 2026

Copy link
Copy Markdown

Deploy → stagingworkflow run
Last updated: 2026-07-10 15:39:14 UTC

  • DB migrations succeeded
  • ⏭️ Edge functions skipped (no changes)

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Implements Issue #139’s “single migration + phase override” slice: adds a nullable phase_override to festival_editions, introduces set_ratings storage, and centralizes the rule effectivePhase = override ?? derived with an admin control to set/clear the override.

Changes:

  • Adds a Supabase migration introducing festival_phase, festival_editions.phase_override, and a new set_ratings table with RLS mirroring votes.
  • Introduces getEffectiveFestivalPhase and updates useFestivalPhase() to use the override-first seam (with unit tests).
  • Adds an admin UI control beside ScheduleRevealControl for Core Team to set/clear the phase override.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
supabase/migrations/20260710010000_add_phase_override_and_set_ratings.sql Adds festival_phase enum, phase_override column, and set_ratings table + RLS/trigger.
src/pages/admin/festivals/PhaseOverrideControl.tsx New admin control to set/clear phase_override.
src/pages/admin/festivals/FestivalEdition.tsx Places the new override control beside the existing schedule reveal control.
src/lib/festivalPhase.ts Adds getEffectiveFestivalPhase (override ?? derived).
src/lib/festivalPhase.test.ts Unit tests covering override precedence and null fallthrough.
src/integrations/supabase/types.ts Updates generated DB typings for festival_phase, phase_override, and set_ratings.
src/hooks/useFestivalPhase.ts Switches hook to read effective phase (override-first).
docs/prd/festival-phases/0-epic.md Adds the festival phases epic doc.
docs/prd/festival-phases/1-foundation-pre-schedule-planning.md Adds PRD for PR 1 scope and decisions.
docs/prd/festival-phases/2-live-phase.md Adds PRD for PR 2 scope and decisions.
docs/prd/festival-phases/3-post-festival.md Adds PRD for PR 3 scope and decisions (override + ratings).

Comment thread supabase/migrations/20260710010000_add_phase_override_and_set_ratings.sql Outdated
Comment thread supabase/migrations/20260710010000_add_phase_override_and_set_ratings.sql Outdated
Comment thread src/pages/admin/festivals/PhaseOverrideControl.tsx Outdated
Comment thread src/pages/admin/festivals/PhaseOverrideControl.tsx Outdated
claude added 4 commits July 10, 2026 15:30
Adds the epic's one schema change: a nullable phase_override column on
festival_editions and the set_ratings table (RLS mirrors votes) for a
later rating ticket. Extends getFestivalPhase with
getEffectiveFestivalPhase (override ?? derived) and wires it through
useFestivalPhase, plus a Core Team admin control to set/clear the
override beside ScheduleRevealControl.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FUwNzs67viT4UnYJwqjSWo
- Drop idx_set_ratings_user_set: redundant with the unique constraint's
  own index on the same columns.
- Point the set_ratings comment at the actual PRD doc instead of a
  nonexistent ADR-0004.
- Guard the phase-override Select's onValueChange with a type predicate
  instead of casting an arbitrary string to FestivalPhase.
Select value={override ?? undefined} didn't reliably reset the
trigger's displayed label back to the placeholder after clearing, since
Radix Select doesn't round-trip a controlled value through undefined.
Making "Automatic" a real option keeps the value always a defined
string and removes the separate clear button.
Now that both the phase-driven redirect (#137) and the phase override
(#139) are in the same branch, wire the redirect through
getEffectiveFestivalPhase instead of raw getFestivalPhase — an admin
override now also determines the landing tab, not just the banner and
tab label.
@chiptus

chiptus commented Jul 10, 2026

Copy link
Copy Markdown
Owner Author

do you think instead of "derived" we can say in the select "automatic(actual)"?
so when the derived state is live it will be "automatic(live)"

"Automatic (derived)" didn't say what "derived" currently resolves to.
Compute the derived phase alongside the override in FestivalEdition
and show it, e.g. "Automatic (Live)".

chiptus commented Jul 10, 2026

Copy link
Copy Markdown
Owner Author

Done — the "Automatic" option now shows the currently-derived phase, e.g. "Automatic (Live)" or "Automatic (Planning)", recomputed live from the edition's reveal level + dates + festival timezone.


Generated by Claude Code

@chiptus chiptus merged commit 4252c5c into main Jul 10, 2026
14 checks passed
@chiptus chiptus deleted the claude/issue-139-phase-override-migration branch July 10, 2026 15:47
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.

Festival phase: migration + admin phase override

3 participants