Skip to content

feat: add GET /reports endpoint — list previously generated reports w…#171

Merged
BigBen-7 merged 1 commit intoLead-Studios:mainfrom
Kaylahray:get-reports-endpoint
Mar 27, 2026
Merged

feat: add GET /reports endpoint — list previously generated reports w…#171
BigBen-7 merged 1 commit intoLead-Studios:mainfrom
Kaylahray:get-reports-endpoint

Conversation

@Kaylahray
Copy link
Copy Markdown
Contributor

feat: add GET /reports endpoint — list previously generated reports with download links

Closes #152

What changed

  • generated_reports Postgres table — created on startup via CREATE TABLE IF NOT EXISTS; backfilled from the reports/ directory for any pre-existing files.
  • POST /generate-daily-report — now inserts a metadata row (filename, report_date, format, size_bytes, generated_at) into generated_reports after writing each file.
  • GET /reports (ADMIN) — returns up to 100 most-recent reports with download_url for each entry.
  • GET /reports/download/{filename} (ADMIN) — streams the file as a FileResponse; validates filename against a strict allow-list pattern to prevent path traversal.
  • src/types_custom.py — added ReportItem and ReportsListResponse Pydantic models.
  • tests/test_reports_list.py — 20+ tests covering empty list, multiple reports, DB error handling, CSV/JSON download, 404, path-traversal rejection, and auth enforcement.

Checklist

  • generated_reports table with Postgres-backed metadata
  • Startup scan backfills existing files
  • GET /reports capped at 100 most recent, ADMIN-gated
  • GET /reports/download/{filename} streams file, ADMIN-gated
  • Path traversal blocked (400 on invalid filename)
  • Tests written for list + download endpoints

@drips-wave
Copy link
Copy Markdown

drips-wave bot commented Mar 26, 2026

@Kaylahray Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@BigBen-7 BigBen-7 merged commit f270dc9 into Lead-Studios:main Mar 27, 2026
0 of 3 checks 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.

feat: add GET /reports endpoint — list previously generated reports with download links

2 participants