diff --git a/actions/candidates.ts b/actions/candidates.ts index c6e670d..5af86b2 100644 --- a/actions/candidates.ts +++ b/actions/candidates.ts @@ -517,7 +517,7 @@ export async function getMoveWeekendOptions( // Eligible targets: same gender, not finished, excluding the current weekend const { data: weekends, error: weekendsError } = await supabase .from('weekends') - .select('id, type, title, start_date, weekend_groups(number)') + .select('id, type, start_date, weekend_groups(number)') .eq('type', currentWeekend.type) .neq('id', currentWeekend.id) .in('status', [WeekendStatus.PLANNING, WeekendStatus.ACTIVE]) diff --git a/actions/user-experience.ts b/actions/user-experience.ts index 2cab9f5..3ecd7dd 100644 --- a/actions/user-experience.ts +++ b/actions/user-experience.ts @@ -45,8 +45,7 @@ export async function getUserServiceHistory( weekends ( id, type, - start_date, - title + start_date ) ` ) diff --git a/components/navbar/navbar-server.tsx b/components/navbar/navbar-server.tsx index 6b29cff..80a8557 100644 --- a/components/navbar/navbar-server.tsx +++ b/components/navbar/navbar-server.tsx @@ -5,6 +5,7 @@ import { Permission } from '@/lib/security' import { getActiveWeekends } from '@/services/weekend' import { isOk } from '@/lib/results' import { WeekendType } from '@/lib/weekend/types' +import { formatWeekendGroupTitle } from '@/lib/weekend' import { formatDate } from '@/lib/utils' import { isNil } from 'lodash' @@ -75,7 +76,7 @@ async function getNavElements(): Promise { .join(' • ') featuredContent = { - title: `DTTD #${mensWeekend.number}`, + title: formatWeekendGroupTitle(mensWeekend.number), description: dateDescription !== '' ? dateDescription : 'View details and sign up', linkText: 'View weekend details', diff --git a/database.types.ts b/database.types.ts index 0408055..24935b9 100644 --- a/database.types.ts +++ b/database.types.ts @@ -931,7 +931,6 @@ export type Database = { id: string start_date: string status: string | null - title: string | null type: Database['public']['Enums']['weekend_type'] } Insert: { @@ -941,7 +940,6 @@ export type Database = { id?: string start_date: string status?: string | null - title?: string | null type: Database['public']['Enums']['weekend_type'] } Update: { @@ -951,7 +949,6 @@ export type Database = { id?: string start_date?: string status?: string | null - title?: string | null type?: Database['public']['Enums']['weekend_type'] } Relationships: [ diff --git a/lib/weekend/labels.test.ts b/lib/weekend/labels.test.ts index ef64d72..c4b0c1f 100644 --- a/lib/weekend/labels.test.ts +++ b/lib/weekend/labels.test.ts @@ -22,7 +22,6 @@ function makeWeekend(overrides: Partial = {}): Weekend { end_date: '2026-03-15', number: 12, status: WeekendStatus.PLANNING, - title: null, type: WeekendType.MENS, groupId: 'group-id', ...overrides, @@ -68,9 +67,11 @@ describe('getWeekendLabel', () => { }) describe('formatWeekendTitle', () => { - it('derives the label from the weekend record, ignoring any stored title', () => { - const weekend = makeWeekend({ title: 'Mens DTTD#12' }) - expect(formatWeekendTitle(weekend)).toBe('DTTD Mens #12') + it('derives the label from the weekend record', () => { + expect(formatWeekendTitle(makeWeekend())).toBe('DTTD Mens #12') + expect(formatWeekendTitle(makeWeekend({ type: WeekendType.WOMENS }))).toBe( + 'DTTD Womens #12' + ) }) it('degrades gracefully when the weekend has no group number', () => { diff --git a/lib/weekend/types.ts b/lib/weekend/types.ts index a2dabbc..4512664 100644 --- a/lib/weekend/types.ts +++ b/lib/weekend/types.ts @@ -51,7 +51,6 @@ export type Weekend = { /** Weekend number, sourced from weekend_groups.number via join. Null until Task 3 join is added. */ number: number | null status: WeekendStatusValue | null - title: string | null type: WeekendType groupId: string | null } diff --git a/supabase/migrations/20260812100000_drop_weekends_title.sql b/supabase/migrations/20260812100000_drop_weekends_title.sql new file mode 100644 index 0000000..3e516ec --- /dev/null +++ b/supabase/migrations/20260812100000_drop_weekends_title.sql @@ -0,0 +1,23 @@ +-- Drop weekends.title. +-- +-- The column stored a free-text label ("DTTD#11", "Mens DTTD#12", "DTTD Mens +-- #42" — three formats accumulated over time) that was written once at weekend +-- creation and never editable through the UI. It duplicated data we already +-- store: weekend_groups.number and weekends.type. +-- +-- Labels are now derived at render time from those two fields, so nothing reads +-- or writes this column. See lib/weekend/labels.ts. +-- +-- SAFETY: any weekend whose title was hand-edited to something non-canonical +-- loses that text. Verify before applying: +-- SELECT id, type, title, group_id FROM public.weekends ORDER BY start_date; +-- +-- Weekends must also be attached to a numbered group, or their derived label +-- will have no number. Verify this returns zero rows before applying: +-- SELECT w.id, w.type, w.title +-- FROM public.weekends w +-- LEFT JOIN public.weekend_groups g ON g.id = w.group_id +-- WHERE w.group_id IS NULL OR g.number IS NULL; + +ALTER TABLE public.weekends + DROP COLUMN IF EXISTS title; diff --git a/supabase/seed.sql b/supabase/seed.sql index 3054984..66bb939 100644 --- a/supabase/seed.sql +++ b/supabase/seed.sql @@ -995,26 +995,26 @@ INSERT INTO public.weekend_groups (id, number) VALUES ('d0000004-0000-4000-8000-000000000004', 45), ('d0000005-0000-4000-8000-000000000005', 46); -INSERT INTO public.weekends (id, group_id, type, title, start_date, end_date, status) VALUES +INSERT INTO public.weekends (id, group_id, type, start_date, end_date, status) VALUES -- Weekend Group 1: FINISHED (Spring 2024) - ('c0000001-0000-4000-8000-000000000001', 'd0000001-0000-4000-8000-000000000001', 'MENS', 'DTTD Mens #42', '2024-03-14', '2024-03-17', 'FINISHED'), - ('c0000002-0000-4000-8000-000000000001', 'd0000001-0000-4000-8000-000000000001', 'WOMENS', 'DTTD Womens #42', '2024-03-14', '2024-03-17', 'FINISHED'), + ('c0000001-0000-4000-8000-000000000001', 'd0000001-0000-4000-8000-000000000001', 'MENS', '2024-03-14', '2024-03-17', 'FINISHED'), + ('c0000002-0000-4000-8000-000000000001', 'd0000001-0000-4000-8000-000000000001', 'WOMENS', '2024-03-14', '2024-03-17', 'FINISHED'), -- Weekend Group 2: FINISHED (Fall 2024) - ('c0000003-0000-4000-8000-000000000002', 'd0000002-0000-4000-8000-000000000002', 'MENS', 'DTTD Mens #43', '2024-09-19', '2024-09-22', 'FINISHED'), - ('c0000004-0000-4000-8000-000000000002', 'd0000002-0000-4000-8000-000000000002', 'WOMENS', 'DTTD Womens #43', '2024-09-19', '2024-09-22', 'FINISHED'), + ('c0000003-0000-4000-8000-000000000002', 'd0000002-0000-4000-8000-000000000002', 'MENS', '2024-09-19', '2024-09-22', 'FINISHED'), + ('c0000004-0000-4000-8000-000000000002', 'd0000002-0000-4000-8000-000000000002', 'WOMENS', '2024-09-19', '2024-09-22', 'FINISHED'), -- Weekend Group 3: FINISHED (Spring 2025) - ('c0000005-0000-4000-8000-000000000003', 'd0000003-0000-4000-8000-000000000003', 'MENS', 'DTTD Mens #44', '2025-03-13', '2025-03-16', 'FINISHED'), - ('c0000006-0000-4000-8000-000000000003', 'd0000003-0000-4000-8000-000000000003', 'WOMENS', 'DTTD Womens #44', '2025-03-13', '2025-03-16', 'FINISHED'), + ('c0000005-0000-4000-8000-000000000003', 'd0000003-0000-4000-8000-000000000003', 'MENS', '2025-03-13', '2025-03-16', 'FINISHED'), + ('c0000006-0000-4000-8000-000000000003', 'd0000003-0000-4000-8000-000000000003', 'WOMENS', '2025-03-13', '2025-03-16', 'FINISHED'), -- Weekend Group 4: ACTIVE (Fall 2025 - current) - ('c0000007-0000-4000-8000-000000000004', 'd0000004-0000-4000-8000-000000000004', 'MENS', 'DTTD Mens #45', '2025-09-18', '2025-09-21', 'ACTIVE'), - ('c0000008-0000-4000-8000-000000000004', 'd0000004-0000-4000-8000-000000000004', 'WOMENS', 'DTTD Womens #45', '2025-09-18', '2025-09-21', 'ACTIVE'), + ('c0000007-0000-4000-8000-000000000004', 'd0000004-0000-4000-8000-000000000004', 'MENS', '2025-09-18', '2025-09-21', 'ACTIVE'), + ('c0000008-0000-4000-8000-000000000004', 'd0000004-0000-4000-8000-000000000004', 'WOMENS', '2025-09-18', '2025-09-21', 'ACTIVE'), -- Weekend Group 5: PLANNING (Spring 2026 - future) - ('c0000009-0000-4000-8000-000000000005', 'd0000005-0000-4000-8000-000000000005', 'MENS', 'DTTD Mens #46', '2026-03-12', '2026-03-15', 'PLANNING'), - ('c0000010-0000-4000-8000-000000000005', 'd0000005-0000-4000-8000-000000000005', 'WOMENS', 'DTTD Womens #46', '2026-03-12', '2026-03-15', 'PLANNING'); + ('c0000009-0000-4000-8000-000000000005', 'd0000005-0000-4000-8000-000000000005', 'MENS', '2026-03-12', '2026-03-15', 'PLANNING'), + ('c0000010-0000-4000-8000-000000000005', 'd0000005-0000-4000-8000-000000000005', 'WOMENS', '2026-03-12', '2026-03-15', 'PLANNING'); -- ============================================================================= -- SECTION: Events for DTTD #45