Skip to content

Feat/insights csv - #26

Merged
Mahakisore7 merged 5 commits into
mainfrom
feat/insights-csv
Oct 2, 2026
Merged

Mahakisore7 merged 5 commits into
mainfrom
feat/insights-csv

Conversation

@Mahakisore7

Copy link
Copy Markdown
Contributor

Phase

No phase doc: enterprise readiness (organizers take Insights into their own reports).

Summary

  • GET /api/insights/export?report=gaps|questions|moments|daily|sessions: the full list (up to 1000 rows) as text/csv; charset=utf-8 with a byte-order mark (Excel opens Hindi questions correctly), as an attachment named pravaha-<report>-<date>.csv (India date), Cache-Control: private, no-store.
  • Same access rules as /api/insights: organizers get everything; the demo Studio gets the same filtered aggregates.
  • CSV injection: learner-typed cells starting with = + - @, a tab or a carriage return get a leading '.
  • Each Insights card has a "CSV ↓" link. Moments and sessions rows link back to the recording.
  • getInsights takes limit/sessionsLimit (Studio unchanged at 10/6). API.md, openapi.yaml, SECURITY.md, OBSERVABILITY.md (insights.export).

How to verify

  1. Preview → Studio → Insights: five "CSV ↓" links; "Most asked" downloads pravaha-questions-<date>.csv and opens in Excel/Sheets with the Hindi question intact.
  2. <preview>/api/insights/export?report=nope → 400 invalid_report.

Checklist

  • Meets the linked phase doc's acceptance criteria (n/a: all five reports checked on the preview)
  • Tests added/updated per the phase doc (tests/unit/csv.test.ts: quoting, formula neutralising, each report)
  • pnpm lint, pnpm typecheck, pnpm test pass
  • No secrets or .env values in this diff
  • Docs made inaccurate by this change are updated in this PR
  • No AI attribution in commits or this description (docs/GIT_WORKFLOW.md)

GET /api/insights/export?report=gaps|questions|moments|daily|sessions returns the full list (up to 1000 rows) as a UTF-8 CSV with a BOM, under the same organizer/demo rules as /api/insights. Learner-typed cells that would run as a spreadsheet formula get a leading quote (CSV injection). Each Insights card gets a CSV download link. API.md, openapi.yaml, SECURITY.md, OBSERVABILITY.md.
@vercel

vercel Bot commented Oct 2, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
pravaha Ready Ready Preview Oct 2, 2026 7:11pm UTC

@Mahakisore7
Mahakisore7 merged commit 92cfd0d into main Oct 2, 2026
3 checks passed

This branch was successfully deployed

1 active deployment
Preview — 6b59ef26 Deployed Oct 2, 2026 by vercel[bot]
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