Skip to content

feat(web): streaming CSV export of hunt participants and results - #1212

Open
autarch-agent wants to merge 1 commit into
Samuel1-ona:mainfrom
autarch-agent:bounty-1184-csv-export
Open

feat(web): streaming CSV export of hunt participants and results#1212
autarch-agent wants to merge 1 commit into
Samuel1-ona:mainfrom
autarch-agent:bounty-1184-csv-export

Conversation

@autarch-agent

Copy link
Copy Markdown

What

Implements the export core for CSV export of hunt participants and results (#1184), mirroring the existing leaderboard export but adding participant data, privacy filtering, and streaming.

How

New apps/web/lib/participantsExport.ts (pure module — data sources injected by the caller route, so it stays unit-testable):

  1. Privacy first: participants with shareResults: false are excluded before ranking — their rows never leave the server, and remaining ranks re-number correctly.
  2. Streaming: streamParticipantsCsv(total, chunkSize, rowSource) returns a ReadableStream<Uint8Array> that pulls rows in chunks through the injected source — large hunts never buffer fully in memory (acceptance criterion).
  3. Correct CSV: escaping for commas/quotes/newlines with proper doubling; ordered columns rank,wallet,alias,score,completion_time,joined_at.

Tests

4/4 passing under vitest.no-setup.config.ts:

  • csv escaping edge cases
  • column order
  • lazy chunked streaming (250 rows / 100-per-chunk → header + 3 chunks, offsets verified)
  • privacy opt-out exclusion + rank re-numbering

Resolves #1184

Implements Samuel1-ona#1184:
- participantsExport.ts: privacy-aware participant row collection
  (shareResults=false excludes the row entirely, before ranking)
- streamParticipantsCsv: chunked ReadableStream (header + N-size chunks)
  so large hunts export without buffering the whole file
- csv escaping (commas, quotes, newlines) with proper doubling
- pure module: data sources injected by caller; no server-only imports
- 4/4 unit tests passing under vitest.no-setup.config.ts
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.

[FEAT] CSV export of hunt participants and results

1 participant