From de225bc1cd69d3c1f8fded58cb8ddab30552b27d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 29 Mar 2026 23:24:40 +0000 Subject: [PATCH] Replace dummy/bogus reports data with real API data on /reports page Agent-Logs-Url: https://github.com/christianlouis/dmarq/sessions/c6e36fd9-00c9-4000-985f-f7a42e2ba451 Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com> --- backend/app/api/api_v1/endpoints/reports.py | 50 +++++++++++++ backend/app/templates/reports.html | 82 ++++++--------------- 2 files changed, 72 insertions(+), 60 deletions(-) diff --git a/backend/app/api/api_v1/endpoints/reports.py b/backend/app/api/api_v1/endpoints/reports.py index 2e4618a..6d6da0b 100644 --- a/backend/app/api/api_v1/endpoints/reports.py +++ b/backend/app/api/api_v1/endpoints/reports.py @@ -132,6 +132,20 @@ class ReportSummary(BaseModel): failed_count: int +class AllReportsItem(BaseModel): + """Single report item for the cross-domain reports list""" + + report_id: str + domain: str + org_name: str + begin_date: str + end_date: str + total_count: int + passed_count: int + failed_count: int + pass_rate: float + + class PaginatedReportResponse(BaseModel): """Paginated reports response model""" @@ -216,6 +230,42 @@ async def upload_report(file: UploadFile = File(...)): ) from e +@router.get("", response_model=List[AllReportsItem]) +async def get_all_reports(): + """ + Get all DMARC reports across all domains, sorted by end_date descending. + """ + store = ReportStore.get_instance() + domains = store.get_domains() + + all_reports: List[AllReportsItem] = [] + for domain in domains: + domain_reports = store.get_domain_reports(domain) + for report in domain_reports: + summary = report.get("summary", {}) + total = summary.get("total_count", 0) + passed = summary.get("passed_count", 0) + pass_rate = round(passed / total * 100, 1) if total > 0 else 0.0 + all_reports.append( + AllReportsItem( + report_id=report.get("report_id", ""), + domain=domain, + org_name=report.get("org_name", ""), + begin_date=str(report.get("begin_date", "")), + end_date=str(report.get("end_date", "")), + total_count=total, + passed_count=passed, + failed_count=summary.get("failed_count", 0), + pass_rate=pass_rate, + ) + ) + + # end_date is stored in ISO 8601 format (YYYY-MM-DDTHH:MM:SS), so lexicographic + # sorting produces correct chronological order. + all_reports.sort(key=lambda r: r.end_date, reverse=True) + return all_reports + + @router.get("/domains", response_model=List[str]) async def get_domains(): """ diff --git a/backend/app/templates/reports.html b/backend/app/templates/reports.html index 17ed501..ed0bb71 100644 --- a/backend/app/templates/reports.html +++ b/backend/app/templates/reports.html @@ -23,14 +23,6 @@ -