Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion actions/candidates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down
3 changes: 1 addition & 2 deletions actions/user-experience.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ export async function getUserServiceHistory(
weekends (
id,
type,
start_date,
title
start_date
)
`
)
Expand Down
3 changes: 2 additions & 1 deletion components/navbar/navbar-server.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down Expand Up @@ -75,7 +76,7 @@ async function getNavElements(): Promise<NavElement[]> {
.join(' • ')

featuredContent = {
title: `DTTD #${mensWeekend.number}`,
title: formatWeekendGroupTitle(mensWeekend.number),
description:
dateDescription !== '' ? dateDescription : 'View details and sign up',
linkText: 'View weekend details',
Expand Down
3 changes: 0 additions & 3 deletions database.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -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: {
Expand All @@ -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: [
Expand Down
9 changes: 5 additions & 4 deletions lib/weekend/labels.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ function makeWeekend(overrides: Partial<Weekend> = {}): Weekend {
end_date: '2026-03-15',
number: 12,
status: WeekendStatus.PLANNING,
title: null,
type: WeekendType.MENS,
groupId: 'group-id',
...overrides,
Expand Down Expand Up @@ -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', () => {
Expand Down
1 change: 0 additions & 1 deletion lib/weekend/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
23 changes: 23 additions & 0 deletions supabase/migrations/20260812100000_drop_weekends_title.sql
Original file line number Diff line number Diff line change
@@ -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;
22 changes: 11 additions & 11 deletions supabase/seed.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down