diff --git a/.last-branch b/.last-branch index 0390956..37742c9 100644 --- a/.last-branch +++ b/.last-branch @@ -1 +1 @@ -v20260104-13-reports-jobs-deduplicate-job-name-column +v20260104-14-reports-stats-total-runs-success-rate-fix 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 93e4c9b..1f1035e 100644 --- a/containers/backupchecks/src/backend/app/main/routes_reporting_api.py +++ b/containers/backupchecks/src/backend/app/main/routes_reporting_api.py @@ -812,8 +812,12 @@ def _get_success_rate_keys_from_report(report: ReportDefinition, view_key: str = cols = (rc.get("columns") or {}) if isinstance(rc, dict) else {} view_cols = cols.get(view_key) if isinstance(cols, dict) else None + # "Configured" means the user explicitly saved a column list for this view. + # This includes the case where they saved an empty list (all columns off). + configured = isinstance(view_cols, list) + selected = set() - if isinstance(view_cols, list): + if configured: for k in view_cols: if not isinstance(k, str): continue @@ -828,10 +832,15 @@ def _get_success_rate_keys_from_report(report: ReportDefinition, view_key: str = # Always include success_count in the denominator to prevent odd rates. out.add("success_count") - # If nothing was selected (or config missing), fall back to all status keys. - if len(out) == 1 and "success_count" in out and not selected: + # If the user explicitly configured an empty column list for this view, + # default the denominator to the most common "signal" statuses so totals and + # rates remain meaningful (exclude missed unless explicitly selected). + if configured and not selected: + out = {"success_count", "failed_count"} + + # If config is missing for this view, fall back to all status keys. + if not configured and not selected: out = set(status_keys) - out.add("success_count") return out diff --git a/docs/changelog.md b/docs/changelog.md index 3aafd86..1b06deb 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -298,6 +298,15 @@ - Added migration logic to automatically clean up existing report configurations containing duplicate job name columns. - Ensured report rendering strictly follows the selected columns; when no columns are selected, no table data is shown. +--- + +## v20260104-14-reports-stats-total-runs-success-rate-fix + +- Fixed incorrect Total runs calculation by only counting selected run statuses. +- Corrected Success rate calculation to be based on Success / (Success + Failed). +- Prevented non-selected statuses (such as Missed) from affecting totals and percentages. +- Ensured consistency between displayed counts and calculated percentages in reports. + ================================================================================================================================================ ## v0.1.15