Description
POST /generate-daily-report saves files to the reports/ directory and returns the file path, but there is no way to list or re-download previously generated reports without direct filesystem access. In a containerised environment the path is ephemeral anyway — reports must be accessible via the API.
Requirements & context
GET /reports (ADMIN) returns a list of generated reports:
{ "reports": [ { "filename": "daily_report_2025-01-01_...", "report_date": "2025-01-01", "format": "csv", "size_bytes": 4096, "generated_at": "ISO", "download_url": "/reports/download/daily_report_..." } ] }
GET /reports/download/{filename} (ADMIN) streams the file as a FileResponse
- Store report metadata in a
generated_reports Postgres table instead of relying on the filesystem
- On startup, scan
reports/ and populate the table with any existing files
- Write tests for list and download endpoints
Suggested execution
git checkout -b feat/reports-list-download-api
- Create
generated_reports table
- Add routes to
src/main.py
- Update
generate_daily_report_csv to insert metadata row
- Write tests
Guidelines
- Cap listing at 100 most recent reports
- PR must include:
Closes #[issue_id]
- Timeframe: 72 hours
Description
POST /generate-daily-reportsaves files to thereports/directory and returns the file path, but there is no way to list or re-download previously generated reports without direct filesystem access. In a containerised environment the path is ephemeral anyway — reports must be accessible via the API.Requirements & context
GET /reports(ADMIN) returns a list of generated reports:{ "reports": [ { "filename": "daily_report_2025-01-01_...", "report_date": "2025-01-01", "format": "csv", "size_bytes": 4096, "generated_at": "ISO", "download_url": "/reports/download/daily_report_..." } ] }GET /reports/download/{filename}(ADMIN) streams the file as aFileResponsegenerated_reportsPostgres table instead of relying on the filesystemreports/and populate the table with any existing filesSuggested execution
generated_reportstablesrc/main.pygenerate_daily_report_csvto insert metadata rowGuidelines
Closes #[issue_id]