Repository navigation
Conversation
|
Hi @Aliussman, we should be having a frontend implementation for that feature. Feel free to create issue and PR. Thanks, |
|
Hey @Aliussman, thanks for putting this together, it's a big one and the tests look really thorough! Before I review it for merge there are a few things. Like Marc said, this needs a frontend side, so could you open an issue + PR in fireform-frontend and link them here? It's also conflicting with development in router.py now, so it'll need a rebase. |
5c2a2cb to
abae3db
Compare
|
Thanks @marcvergees and @vharkins1! Both points are done:
|
|
Hey @Aliussman, thanks for turning this around so fast! The rebase and the frontend PR both look great. One bigger change though. Right now the report reads from the Incident, Form and Extraction tables, but nothing on development writes to those (they're from the Pipeline C contract that got pulled in #645), so every report comes back empty. Could you switch it to build from FormSubmission instead? That's where every filled form lives (template_id, input_text, output_pdf_path, created_at). So for a period: total forms filled, a breakdown by template, and a list of the submissions with links to their PDFs. The incident-only parts (categories, NERIS rate, injuries) can come out for now, and the reporting contract should match the new shape. The frontend can mostly stay as it is, it just needs the JSON view updated for the new fields. Thanks, this is solid work! Since this changes the scope of the issue I'd also like @marcvergees and @chetanr25 to look at this. |
Description
Implements periodic report generation API endpoints and async worker execution for monthly, quarterly, and annual department reporting in FireForm as outlined in #557 (part of contract tracker #541).
Key Additions:
POST /api/v1/reports/generate: Asynchronously kicks off periodic report generation; returns202 Acceptedwithreport_id,job_id, andpoll_url.GET /api/v1/reports/{report_id}: Polling and result retrieval. Returns202 Acceptedwithretry_after_secondswhile generating; returns200 OKwith PDF binary or JSON payload (PeriodicReportschema) upon completion; returns404 Not Foundif missing.contracts/path/reporting.yamlandcontracts/schemas/reporting.yaml, mounted incontracts/openapi.yaml.app/api/schemas/reporting.pyand updatedAsyncJobResponseinapp/api/schemas/common.py.create_report,get_report,update_report,get_incidents_in_date_range(with strict UTC timezone awareness),get_forms_for_incidents, andget_extractions_by_idsinapp/db/repositories.py.app/services/reporting.pywith period boundary computation & validation, future period rejection (422 Unprocessable Entitywith codeFUTURE_PERIOD), metrics aggregation (incident types, statuses, forms generated, completeness score, processing time), compliance metrics (NERIS submission rate, delay, overdue count), and ReportLab-based PDF generation.generate_periodic_reportinapp/tasks/report.pyand registered it inapp/core/celery.py.reportlabtorequirements.txtfor PDF rendering.Fixes #557
Type of change
How Has This Been Tested?
tests/test_v1_reports.py(18 tests):POST /api/v1/reports/generate-> 202).422 Unprocessable EntitywithFUTURE_PERIOD).GET /api/v1/reports/{id}-> 202).Content-Type: application/pdf).PeriodicReportschema.404 Not Found).503 Service Unavailable).PYTHONPATH=. pytest→ 331 passed.python -m ruff check app/ tests/→ All checks passed!Test Configuration:
Checklist: