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.