Skip to content

feat: Session Reporting — CSV Export - #35

Merged
WFord26 merged 1 commit into
mainfrom
feat/csv-export
Apr 15, 2026
Merged

WFord26 merged 1 commit into
mainfrom
feat/csv-export

Conversation

@WFord26

@WFord26 WFord26 commented Apr 15, 2026

Copy link
Copy Markdown
Collaborator

Summary

Implements issue #18 — Session Reporting: CSV Export.

Backend

Two new endpoints:

Method Path Auth Description
GET /api/v1/projects/:id/export JWT (PM/engineer) Export sessions for one project
GET /api/v1/export/sessions JWT (PM/admin) Export sessions across all projects

Query parameters:

  • from — ISO date filter (sessions starting after)
  • to — ISO date filter (sessions ending before)
  • status — all, active, or cancelled

CSV format:

Project Name, Session Date, Start Time, End Time, Client First Name, Client Last Name, Client Email, Client Phone, Status, Engineers, Session Notes

Key behaviors:

  • PII-redacted bookings (pii_redacted_at IS NOT NULL) show [redacted] for name, email, phone
  • Proper CSV escaping for fields with commas, quotes, newlines
  • Content-Disposition header with descriptive filename (project_name_sessions_2026-04-14.csv)
  • Cross-project export includes Project Name column; per-project omits it
  • Empty export returns headers-only CSV
  • Engineers column uses STRING_AGG for all assigned engineers per session

Frontend

  • apiDownload() helper in api/client.ts — authenticated file download via blob URL
  • "Export CSV" button on ProjectDetailPage (Signed Up Clients section, visible when bookings exist)
  • "Export All Sessions" button on DashboardPage (PM/admin only)
  • Loading/disabled state during export

Shared

  • exportSessionsQuerySchema Zod validation for query params
  • ExportSessionsQuery contract type

Acceptance Criteria

  • CSV downloads with correct data and formatting
  • Redacted bookings show [redacted] for PII fields
  • Date range filter works correctly
  • Filename includes project name and export date
  • Cross-project export includes project name column
  • Engineers column lists all assigned engineers per session
  • Empty export returns CSV with headers only
  • Parameterized queries (no SQL injection)

Closes #18

- Add GET /api/v1/projects/:id/export for per-project session CSV export
- Add GET /api/v1/export/sessions for cross-project export (PM/admin only)
- Query params: from (ISO date), to (ISO date), status (all/active/cancelled)
- CSV columns: Project Name, Session Date, Start/End Time, Client info, Status, Engineers, Session Notes
- PII-redacted bookings show [redacted] for name, email, phone fields
- Content-Disposition header with descriptive filename (project_name_sessions_date.csv)
- Proper CSV escaping for fields containing commas, quotes, newlines
- Add apiDownload() helper for frontend file downloads with auth
- Export CSV button on ProjectDetailPage (Signed Up Clients section)
- Export All Sessions button on DashboardPage (PM/admin only)
- Add exportSessionsQuerySchema Zod validation
- Add ExportSessionsQuery contract type
@WFord26
WFord26 merged commit 47b8bbb into main Apr 15, 2026
1 check passed
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.

Session Reporting: CSV Export

1 participant