fix: align public schedule page with actual API response schema (#206) #207
No reviewers
Labels
No labels
domain:backend
domain:devops
domain:frontend
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
ldraney/westside-app!207
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "206-fix-public-schedule-api-schema"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
The public schedule page was built against hardcoded fallback data shapes, not the actual
/public/scheduleAPI response. Six field mismatches caused practices and events to silently not render when live API data was returned.Changes
src/routes/(public)/schedule/+page.svelte:DAY_NAMESarray anddayName()helper to convert integerday_of_week(0-6) to day namesformatTime()to convert 24h"HH:MM"strings to"H:MM AM/PM"display formatformatDate()/formatDateRange()for ISO date string formattingLocalin label) instead of nonexistentgroupfield, with fallback compatibility for hardcoded dataevent.titleinstead ofevent.name,formatDateRange(event.start_date, event.end_date)instead ofevent.date, removedevent.teamsreferencegroupByTeam()to usep.label(API field) withp.team_namefallbackTest Plan
npm run buildpasses (confirmed)/schedulepage with API running -- Kings and Queens practices and events should render with correct day names, formatted times, and formatted dates/schedulepage with API down -- fallback data should still render correctly via field fallbacks (event.name,event.date, stringday_of_week)Review Checklist
src/lib/public-api.jsorsrc/lib/api.jsnpm run buildpassesRelated Notes
None.
Related
Closes #206
QA Review
Scope: Single file change (
src/routes/(public)/schedule/+page.svelte), 1 changed file, +103/-18 lines.Findings
Bug caught during review (fixed in
8d0752c):formatTime()would corrupt fallback data. Fallback practices use pre-formatted strings like"2:00 PM". Splitting on:and callingNumber()on"00 PM"producesNaN. Added an AM/PM guard to return pre-formatted strings as-is.All six field mismatches addressed:
event.name->event.title || event.name(fallback-safe)event.date->formatDateRange(event.start_date, event.end_date)withevent.datefallbackevent.teamsremoved (not in API response)p.group-> label-based classification withp.groupfallbackpractice.day_of_weekraw ->dayName()with string passthrough for fallbackpractice.start_time/end_timeraw ->formatTime()with AM/PM guardQueens practice section added -- renders when API returns girls practices, falls back to "contact director" message when empty.
Build passes --
npm run buildconfirmed clean.No prohibited files changed --
public-api.js,api.js, CSS, and fallback constants all untouched.VERDICT: APPROVED
PR #207 Review
DOMAIN REVIEW
Tech stack: SvelteKit (Svelte 5 runes syntax), public-facing schedule page. Single file change:
src/routes/(public)/schedule/+page.svelte(+103/-18).Correctness
DAY_NAMESmapping (0=Monday...6=Sunday): The comment documents "0=Mon...6=Sun" which is an ISO 8601-style zero-indexed convention. This will be correct only if the basketball-api returnsday_of_weekusing this same convention. If the API uses JavaScript'sDate.getDay()convention (0=Sunday, 1=Monday...6=Saturday), every day will render shifted by one. Verify the API contract. The fallback handling (typeof day === 'string'passthrough) is correctly implemented for backward compatibility.formatTime()logic: Correct. Handles null/undefined, passthrough for already-formatted AM/PM strings (fallback data), and proper 24h-to-12h conversion. Edge cases covered: midnight (0:00 -> 12:00 AM), noon (12:00 -> 12:00 PM). ThepadStart(2,'0')for minutes is correct.formatDate()with'T00:00:00'suffix: Good defensive pattern to prevent timezone-offset date shifting when parsing date-only ISO strings.Practice filtering via label: The ternary
p.label ? !p.label.includes('Local') : p.group === 'travel'is a reasonable dual-path filter. Note that any label not containing the substring "Local" is classified as travel -- this is a broad assumption. If the API ever returns labels like "Exhibition" or "Clinic", they would be classified as travel practices.groupByTeam()key change: Usingp.label || p.team_name || 'Practice'means the grouping key changed from team name to label. If multiple practices share the same label but different team names, they will be grouped together. Verify this is the intended behavior.Accessibility
UX
{:else}block for Queens practices renders outside thesection-altdiv structure differently than the{#if}block -- both wrap insection.section-alt > div.containerwhich is consistent.BLOCKERS
None.
The "no tests" situation is consistent with the existing codebase (no test infrastructure exists in westside-landing). This is pre-existing technical debt, not a regression introduced by this PR.
NITS
DAY_NAMES convention verification: While not a blocker for the code itself, the day-of-week mapping is the single highest-risk assumption in this PR. If the API uses 0=Sunday convention, all days render wrong. The PR author should confirm the API contract matches
0=Monday.Label-based filtering fragility: The
p.label.includes('Local')check is string-matching on API data. If the API label format ever changes (e.g., "local" lowercase, or "Community/Local"), the filter breaks silently. Consider a case-insensitive check:p.label.toLowerCase().includes('local').DRY opportunity: The Kings events card template (lines ~172-185) and Queens events card template (lines ~245-258) are nearly identical. A shared
EventCardcomponent or Svelte snippet would reduce duplication. Non-blocking since this duplication existed before this PR.Queens practice section uses
grid-2while Kings local practices usegrid-3. This may be intentional (fewer Queens teams) but worth confirming it is a deliberate layout choice.SOP COMPLIANCE
206-fix-public-schedule-api-schemafollows{issue-number}-{kebab-case-purpose}convention.sveltefile change, no credentials or env filesfix: align public schedule page with actual API response schema (#206)PROCESS OBSERVATIONS
event.title || event.name) is pragmatic and reduces deployment risk.VERDICT: APPROVED