From 6fec78e9e4f2ddf0355d6dd7588de07bf3e137eb Mon Sep 17 00:00:00 2001 From: hermes Date: Mon, 9 Nov 2026 14:18:29 +1000 Subject: [PATCH] fix(analysis): address the two review nits The re-review returned APPROVED with two low-severity notes. - The prose said "Across 15 finished brews", which reads as though there are only 15 brews. It now says "Across 15 of 16 finished brews", so the exclusion is visible in the sentence itself and not only in the card header. - `/api/runs/` did not carry the `suspect` flag that `/api/runs` does, so a consumer of the detail endpoint could not tell an impossible run from a good one. It does now, with a test. 134 tests. --- src/flask/templates/analysis.html | 2 +- src/flask/views/brews.py | 3 +++ tests/test_analysis.py | 17 +++++++++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/flask/templates/analysis.html b/src/flask/templates/analysis.html index a42ad75..a626181 100644 --- a/src/flask/templates/analysis.html +++ b/src/flask/templates/analysis.html @@ -184,7 +184,7 @@

- Across {{ stats.trusted_count }} finished brews the attenuation averages + Across {% if stats.suspect_count %}{{ stats.trusted_count }} of {{ stats.count }}{% else %}{{ stats.count }}{% endif %} finished brews the attenuation averages {{ stats.consistency.mean }}%, with a standard deviation of {{ stats.consistency.stdev }} percentage points and a total range of {{ stats.consistency.spread }} diff --git a/src/flask/views/brews.py b/src/flask/views/brews.py index 28ac62d..02a24c1 100644 --- a/src/flask/views/brews.py +++ b/src/flask/views/brews.py @@ -208,6 +208,9 @@ def api_run(run_id: str): summary = run_summary(run, og_override=meta.get("og_points")) summary["canonical_name"] = meta.get("name") or run.display_name() summary["tap_number"] = meta.get("tap_number") + # The same flag the list endpoint carries, so a consumer of the detail + # endpoint can tell an impossible run from a good one. + summary["suspect"] = bool(implausible_runs([run])) return jsonify(summary) diff --git a/tests/test_analysis.py b/tests/test_analysis.py index 79cd3a0..cdb3dce 100644 --- a/tests/test_analysis.py +++ b/tests/test_analysis.py @@ -361,6 +361,23 @@ def test_a_suspect_run_is_not_the_strongest_brew_in_the_history(logged_in, repo) ) +def test_the_run_detail_api_also_flags_a_suspect_run(logged_in, repo): + """The detail endpoint carries the same flag as the list endpoint. + + A consumer of /api/runs/ must be able to tell an impossible + run from a good one. + """ + _two_runs(repo) + + response = logged_in.get("/api/runs/12") + assert response.status_code == 200 + assert response.get_json()["suspect"] is True + + response = logged_in.get("/api/runs/1") + assert response.status_code == 200 + assert response.get_json()["suspect"] is False + + def test_the_charts_skip_suspect_runs(): """The chart script must leave the suspect runs out.