Skip to content

fix(#266): add midnight Oslo sync and safe cleanup of stale future sessions#267

Merged
ChristopherRotnes merged 1 commit into
masterfrom
fix/266-sporty-sync-same-day-sessions
May 27, 2026
Merged

fix(#266): add midnight Oslo sync and safe cleanup of stale future sessions#267
ChristopherRotnes merged 1 commit into
masterfrom
fix/266-sporty-sync-same-day-sessions

Conversation

@ChristopherRotnes
Copy link
Copy Markdown
Owner

Summary

  • Sporty's API ignores period_start and always returns sessions from tomorrow onwards — same-day sessions can only be captured the night before while Sporty still treats them as "tomorrow"
  • Adds a 22:00 UTC timer run (midnight Oslo CEST) so each day's sessions are captured before the Sporty window rolls forward
  • Adds a safe delete of future gym_calendar rows within the sync window before each upsert, removing cancelled/rescheduled sessions that Sporty has dropped
  • Cleanup is skipped entirely when Sporty returns 0 sessions (guards against API outages) and for backfill runs (shiftDays !== 0)
  • Rows before the next Oslo midnight are never deleted — same-day sessions from the 22:00 UTC run are preserved by later same-day runs

Closes #266

Test plan

  • Verify on the PR staging URL that today's gym_calendar entries are present after the 22:00 UTC run fires tonight
  • Trigger POST /api/sporty-sync manually and confirm deleted count appears in logs alongside upserted
  • Confirm all 92 tests still pass (npm test in app/)
  • Check Azure Function Monitor for sportySyncTimer to confirm the new 22:00 UTC slot fires

🤖 Generated with Claude Code

…e sessions

Sporty's API ignores period_start and always returns sessions from tomorrow
onwards, so same-day sessions could only ever be captured the night before.
Adding a 22:00 UTC timer run (midnight Oslo CEST) ensures next-day sessions
are captured while Sporty still treats them as "tomorrow".

The sync now also deletes future gym_calendar rows within the sync window
before each upsert, removing cancelled/rescheduled sessions that Sporty
has dropped. The cleanup only runs when Sporty returns data (guards against
API outages) and never touches rows before the next Oslo midnight (preserves
same-day sessions from the 22:00 UTC run across later runs in the same day).
Backfill runs (shiftDays != 0) skip the cleanup entirely.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@ChristopherRotnes ChristopherRotnes force-pushed the fix/266-sporty-sync-same-day-sessions branch from bc84879 to 3f1f36e Compare May 27, 2026 20:36
@github-actions
Copy link
Copy Markdown

Azure Static Web Apps: Your stage site is ready! Visit it here: https://white-island-090dfd003-267.westeurope.7.azurestaticapps.net

@ChristopherRotnes ChristopherRotnes merged commit 34d0891 into master May 27, 2026
2 checks passed
@ChristopherRotnes ChristopherRotnes deleted the fix/266-sporty-sync-same-day-sessions branch May 27, 2026 20:39
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.

As a developer I want the sporty sync to reliably capture same-day gym sessions so instructors can always link logged workouts to the correct class

1 participant