Skip to content

feat: add status change timestamps to bookings export#1467

Merged
rlho merged 1 commit into
mainfrom
feat/export-status-timestamps
May 13, 2026
Merged

feat: add status change timestamps to bookings export#1467
rlho merged 1 commit into
mainfrom
feat/export-status-timestamps

Conversation

@rlho

@rlho rlho commented May 13, 2026

Copy link
Copy Markdown
Collaborator

Summary of Changes

Adds per-status timestamp columns to the admin CSV export (/api/bookings/export) so auditors can see each status transition, not just the single "End Event Status".

New columns (in NY timezone, format M/d/yyyy h:mm a):

  • Requested At
  • First Approved At
  • Final Approved At
  • Declined At
  • Checked In At
  • Checked Out At
  • No Show At
  • Canceled At
  • Closed At

This unblocks downstream audit work — e.g. a Late Cancellation tally computed from Canceled At - Booking Start in the existing App Script. Values are read directly from the per-status fields already present on {tenant}-bookings documents; no new collection joins.

Also hardens the date conversion path: switches to the shared toFirebaseTimestamp helper from components/src/client/utils/serverDate.ts and adds a small safeFormat wrapper. Bookings with malformed/legacy timestamp values now render an empty cell instead of crashing the entire export with RangeError: Invalid time value. This fix also covers the pre-existing Booking Start/End Date/Time columns.

Schema Changes

  • No tenant schema changes
  • Schema changed (describe below)

Checklist

  • I linked relevant issue(s) in the Development section
  • I checked for existing implementations and confirmed there is no duplication
  • I thoroughly tested this feature locally
  • I added or updated unit tests (or explained why not in the PR description)
  • I attached screenshots or a video demonstrating the feature (or explained why not in the PR description)
  • I incorporated Copilot's feedback (or explained why not in the PR description), and marked conversations as resolved
  • I confirmed my PR passed all unit and end-to-end (E2E) tests
  • I confirmed there are no conflicts
  • I requested a code review from at least one other teammate

No unit tests added: the route has no existing test scaffold and the change is mostly column wiring + delegation to an already-tested helper.

Screenshots / Video

CSV output verified locally against the MC dev dataset: new columns populate for bookings with transitions and stay empty for un-traversed statuses; bookings that previously triggered a 500 due to legacy timestamp shapes now export cleanly with empty cells in the affected columns.

Adds per-status timestamp columns (Requested/First Approved/Final
Approved/Declined/Checked In/Checked Out/No Show/Canceled/Closed) to the
admin CSV export so auditors can see each transition, not just the final
status. Enables downstream calculations like late cancellation (cancel
within 48h of start).

Switches the date conversion to the shared `toFirebaseTimestamp` helper
and adds a `safeFormat` wrapper so unparseable values render as empty
cells instead of crashing the export with `RangeError: Invalid time
value`.
Copilot AI review requested due to automatic review settings May 13, 2026 16:50

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds per-status transition timestamp columns (Requested At, First/Final Approved At, Declined At, Checked In/Out At, No Show At, Canceled At, Closed At) to the admin CSV export, and hardens timestamp parsing by delegating to the shared toFirebaseTimestamp helper with a safeFormat wrapper that returns "" for unparseable values.

Changes:

  • Switch local toDate to use toFirebaseTimestamp and return null on bad/missing inputs.
  • Add safeFormat and reuse it for both existing Booking Start/End columns and the new status timestamp columns.
  • Guard calculateTimeInUse against null toDate results.

@rlho rlho merged commit 61e6254 into main May 13, 2026
15 checks passed
@rlho rlho linked an issue May 13, 2026 that may be closed by this pull request
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.

Add status history and timestamps details to the data export

2 participants