From fdeeaef0e65644c1180b666c82d961139994784b Mon Sep 17 00:00:00 2001 From: Ivo Oskamp Date: Sun, 4 Jan 2026 16:02:09 +0100 Subject: [PATCH] Auto-commit local changes before build (2026-01-04 16:02:09) --- .last-branch | 2 +- .../src/backend/app/main/routes_reporting_api.py | 16 ++++++++++++---- docs/changelog.md | 8 ++++++++ 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/.last-branch b/.last-branch index 92ac91b..6c6c6f2 100644 --- a/.last-branch +++ b/.last-branch @@ -1 +1 @@ -v20260104-09-reports-html-total-runs-selection-and-jobs-text-column-remove +v20260104-10-reports-html-export-fix-stats-view-and-total-runs diff --git a/containers/backupchecks/src/backend/app/main/routes_reporting_api.py b/containers/backupchecks/src/backend/app/main/routes_reporting_api.py index 95df3dc..7ae6504 100644 --- a/containers/backupchecks/src/backend/app/main/routes_reporting_api.py +++ b/containers/backupchecks/src/backend/app/main/routes_reporting_api.py @@ -870,11 +870,15 @@ def _compute_success_rate(success: int, warning: int, failed: int, missed: int, -def _build_report_stats_payload(report_id: int) -> dict: +def _build_report_stats_payload(report_id: int, view_key: str = "summary") -> dict: """Compute summary and chart datasets for a generated report.""" report = ReportDefinition.query.get_or_404(report_id) - include_keys = _get_success_rate_keys_from_report(report, view_key=view) + view_key = (view_key or "summary").strip().lower() + if view_key not in ("summary", "snapshot", "jobs"): + view_key = "summary" + + include_keys = _get_success_rate_keys_from_report(report, view_key=view_key) with db.engine.connect() as conn: status_rows = conn.execute( @@ -1060,7 +1064,11 @@ def api_reports_stats(report_id: int): if err is not None: return err - return _build_report_stats_payload(report_id) + view = (request.args.get("view") or "summary").strip().lower() + if view not in ("summary", "snapshot", "jobs"): + view = "summary" + + return _build_report_stats_payload(report_id, view_key=view) @@ -1197,7 +1205,7 @@ def _export_csv_response(report: ReportDefinition, report_id: int, view: str): def _export_html_response(report: ReportDefinition, report_id: int, view: str): - stats = _build_report_stats_payload(report_id) + stats = _build_report_stats_payload(report_id, view_key=view) summary = stats.get("summary") or {} charts = stats.get("charts") or {} trends = charts.get("trends") or [] diff --git a/docs/changelog.md b/docs/changelog.md index 03bff03..5412985 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -264,6 +264,14 @@ - Fixed “Total runs” to only sum the selected status counters (e.g. excluding missed when it’s not selected), instead of using the raw total that included missed runs. - Removed the duplicate “Text” column from the Jobs report view by excluding `object_name` from the Jobs column set and Jobs defaults. +--- + +## v20260104-10-reports-html-export-fix-stats-view-and-total-runs + +### Changed +- Fixed an internal server error when downloading HTML reports by correctly passing the selected view to the stats builder and stats API endpoint. +- Updated the Total runs calculation in the HTML summary to only count run statuses that are selected in the active view. +- Prevented non-selected statuses (such as missed) from being included in the Total runs calculation. ================================================================================================================================================