Extract shared schedule utilities to $lib/schedule-utils.js #219

Open
opened 2026-04-04 22:55:17 +00:00 by forgejo_admin · 0 comments
Contributor

Type

Feature

User Story

story:WS-S13 As an admin, I want the codebase maintainable so that schedule features don't accumulate duplicate logic.

What Broke

Nothing broken — this is a DRY extraction flagged as a nit by QA on both PR #217 and PR #218.

Repro Steps

  1. Open src/routes/(public)/schedule/+page.svelte
  2. Open src/routes/(app)/coach/+page.svelte
  3. Open src/routes/(app)/my-players/+page.svelte
  4. Note duplicated: time formatting (24h→12h), day-of-week names, schedule grouping helpers

Expected Behavior

Shared utilities in src/lib/schedule-utils.js imported by all three pages.

Environment

westside-landing SvelteKit app

Lineage

  • Story: story:WS-S13
  • Arch: arch:landing-site
  • Blocked by: Nothing
  • Blocks: Nothing (quality improvement)

Repo

forgejo_admin/westside-landing

Context

QA reviews on PR #217 (coach dashboard) and PR #218 (parent dashboard) both flagged the same DRY violation: time formatting helpers, day-of-week mapping, and schedule grouping logic are duplicated across 3 files. The public schedule page (#216) was the first implementation; coach and parent pages copied the pattern.

File Targets

  • src/lib/schedule-utils.js — NEW: shared utility module
  • src/routes/(public)/schedule/+page.svelte — refactor to import from shared utils
  • src/routes/(app)/coach/+page.svelte — refactor to import from shared utils
  • src/routes/(app)/my-players/+page.svelte — refactor to import from shared utils

Acceptance Criteria

  • Time formatting (24h→12h with AM/PM) extracted to shared function
  • Day-of-week name mapping extracted to shared constant/function
  • All 3 schedule pages import from $lib/schedule-utils.js
  • No duplicate schedule utility code across pages
  • Zero functional changes — pure refactor

Test Expectations

  • svelte-check passes with 0 errors
  • All 3 schedule pages render identically before and after

Constraints

  • Pure refactor — no behavioral changes
  • No new dependencies

Checklist

  • Create src/lib/schedule-utils.js with shared functions
  • Refactor public schedule page to use shared utils
  • Refactor coach page to use shared utils
  • Refactor parent page to use shared utils
  • Verify svelte-check passes
  • westside-landing#216 (public schedule — first implementation of these utils)
  • westside-landing#217 (coach dashboard — QA flagged DRY nit)
  • westside-landing#218 (parent dashboard — QA flagged same DRY nit)
### Type Feature ### User Story `story:WS-S13` As an admin, I want the codebase maintainable so that schedule features don't accumulate duplicate logic. ### What Broke Nothing broken — this is a DRY extraction flagged as a nit by QA on both PR #217 and PR #218. ### Repro Steps 1. Open `src/routes/(public)/schedule/+page.svelte` 2. Open `src/routes/(app)/coach/+page.svelte` 3. Open `src/routes/(app)/my-players/+page.svelte` 4. Note duplicated: time formatting (24h→12h), day-of-week names, schedule grouping helpers ### Expected Behavior Shared utilities in `src/lib/schedule-utils.js` imported by all three pages. ### Environment westside-landing SvelteKit app ### Lineage - **Story:** `story:WS-S13` - **Arch:** `arch:landing-site` - **Blocked by:** Nothing - **Blocks:** Nothing (quality improvement) ### Repo `forgejo_admin/westside-landing` ### Context QA reviews on PR #217 (coach dashboard) and PR #218 (parent dashboard) both flagged the same DRY violation: time formatting helpers, day-of-week mapping, and schedule grouping logic are duplicated across 3 files. The public schedule page (#216) was the first implementation; coach and parent pages copied the pattern. ### File Targets - `src/lib/schedule-utils.js` — NEW: shared utility module - `src/routes/(public)/schedule/+page.svelte` — refactor to import from shared utils - `src/routes/(app)/coach/+page.svelte` — refactor to import from shared utils - `src/routes/(app)/my-players/+page.svelte` — refactor to import from shared utils ### Acceptance Criteria - Time formatting (24h→12h with AM/PM) extracted to shared function - Day-of-week name mapping extracted to shared constant/function - All 3 schedule pages import from `$lib/schedule-utils.js` - No duplicate schedule utility code across pages - Zero functional changes — pure refactor ### Test Expectations - `svelte-check` passes with 0 errors - All 3 schedule pages render identically before and after ### Constraints - Pure refactor — no behavioral changes - No new dependencies ### Checklist - [ ] Create `src/lib/schedule-utils.js` with shared functions - [ ] Refactor public schedule page to use shared utils - [ ] Refactor coach page to use shared utils - [ ] Refactor parent page to use shared utils - [ ] Verify `svelte-check` passes ### Related - westside-landing#216 (public schedule — first implementation of these utils) - westside-landing#217 (coach dashboard — QA flagged DRY nit) - westside-landing#218 (parent dashboard — QA flagged same DRY nit)
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
ldraney/westside-app#219
No description provided.