Skip to content

fix: 1318 - cancellation within 24 hours + show prior rsvp status - #1323

Open
leahpeker wants to merge 7 commits into
mainfrom
fix-1318-cancellation-window-rsvp-history
Open

fix: 1318 - cancellation within 24 hours + show prior rsvp status#1323
leahpeker wants to merge 7 commits into
mainfrom
fix-1318-cancellation-window-rsvp-history

Conversation

@leahpeker

Copy link
Copy Markdown
Collaborator

Summary

  • Cancellations within the last 24 hours were mislabeled "cancelled same day" due to integer-day truncation ((start - cancelled_at).days == 0). A cancellation the day before could truncate to 0 days. Now compares an actual timedelta against 24 hours, both backend (_cancellations()) and frontend, and the label reads "cancelled within 24 hours".
  • Added EventRSVP.previous_status to track what a guest's RSVP was immediately before they cancelled, so hosts can distinguish "was going" vs. "was maybe" cancellations. Stamped on every write path that transitions an RSVP to cancelled (self-serve and host-driven), plus cleared alongside cancelled_at in the poll-finalize path for consistency. Surfaced in the cancellations list UI.

Test plan

  • make agent-typecheck — clean
  • make agent-lint — clean
  • make agent-frontend-typecheck — clean
  • make agent-frontend-lint — clean
  • make agent-frontend-test — 142/142 files, 1168 passed, 1 skipped
  • Targeted backend tests (test_event_stats.py, test_host_rsvp.py, test_rsvp.py) — 90/90 passed
  • Full backend suite — 1974 passed, 6 pre-existing SQLite-only failures unrelated to this change (SSE/pg_notify + RSVP-capacity race test, need real Postgres row locking)

leahpeker added a commit that referenced this pull request Aug 8, 2026
… (Issue 1318)

test_event_stats.py mixed helper unit tests (_cancellations,
_resolve_cancelled_at, rsvp counts) with API endpoint tests
(TestStatsEndpoint, TestSetAttendance). Split the API endpoint
classes into test_event_attendance_api.py, which imports the
shared fixtures + _auth helper from test_event_stats.

No behavior change — pure move, done ahead of PR #1323 (which
would otherwise push this file over the 500-line hard cap).
@leahpeker
leahpeker force-pushed the fix-1318-cancellation-window-rsvp-history branch 2 times, most recently from f5a4e97 to d82f2d1 Compare August 8, 2026 14:33
@leahpeker
leahpeker force-pushed the fix-1318-cancellation-window-rsvp-history branch from 066d04a to 9268fa4 Compare August 9, 2026 04:56
…y (Issue 1318)

- Add previous_status field to EventRSVP to track status before cancellation
- Fix within_24_hours calculation: now uses timedelta instead of .days==0 (handles same-day edge)
- Wire _resolve_previous_status through upsert + host RSVP write paths
- Clear previous_status when poll finalize resets to ATTENDING
- Add API schema fields for within_24_hours + previous_status
- Frontend: use within24Hours instead of .days===0, render "(was going)" / "(was maybe)" labels
- Tests: 24h boundary cases, previous_status stamping via both endpoints, label rendering
… 1318)

Replaces the within_24_hours elapsed-timedelta check with a same_day
field comparing calendar dates in local time. The app is NY-based, so
settings.TIME_ZONE moves from UTC to America/New_York — this also
fixes timezone.localtime() call sites (invite emails, RSVP views) and
the attendance-reminder cron's day-boundary math to use local days.
…sue 1318)

_attendance_clock.py and send_attendance_reminders.py truncated aware
UTC datetimes to .date() without converting to local time first. Now
that TIME_ZONE is America/New_York, midnight-UTC timestamps landed on
the wrong calendar day. Use timezone.localtime() before truncation.

Also fixes test_attendance_clock.py fixtures that built midnight-UTC
datetimes, which flip to the previous day once localtime() is applied.
…(Issue 1318)

TIME_ZONE was flipped from UTC to America/New_York app-wide, but nothing
in the app calls timezone.activate() — so that global setting was the
sole driver for every bare timezone.localtime() call across the whole
backend (~70+ call sites), not just the 3 that needed local-day
semantics for this fix. Revert TIME_ZONE to UTC and pass a new
settings.LOCAL_DAY_TZ explicitly at the 3 call sites that actually need
"local calendar day" comparisons (_cancellations same_day,
_attendance_clock anchor/last-attendance dates, attendance-reminder
"today"). Same fix, no app-wide blast radius.
…ys_before_event (Issue 1318)

same_day and days_before_event were two separate computations that could
disagree: days_before_event was a raw UTC duration truncated to whole
days, while same_day compared local calendar dates. A cancellation
minutes after a near-midnight event start could yield same_day=True and
days_before_event=-1 simultaneously, and the frontend's day<0 check ran
before the sameDay check, silently dropping the same-day label.

Redefine days_before_event itself as the difference between local
calendar dates (start_date - cancelled_date), so it's timezone-correct
and same_day becomes redundant. Removes the field from the API schema,
model mapping, and frontend — one source of truth instead of two.
@leahpeker
leahpeker force-pushed the fix-1318-cancellation-window-rsvp-history branch from c0d86a7 to 993f419 Compare August 9, 2026 14:01
@leahpeker
leahpeker marked this pull request as ready for review August 9, 2026 14:11
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.

1 participant