fix(analysis): the review findings - rising gravity, undated readings, the band
A second, deeper review of PR #12 found five things the first review did not. All are fixed here. The band was not the band ------------------------- The fermentation curve's shaded range was drawn as ONE dataset with `fill: "+1"`, which fills to the NEXT dataset - and the next dataset was the median line, not the maximum. So the band shaded min-to-median, the upper half of the range was drawn as a hairline but never shaded, and the tooltip said "range min to max" while the picture showed something else. The band is now two datasets - the min curve filled down to a max curve - with the max hidden from the legend. Rising gravity -------------- `attenuation_percent` rejected a final gravity below 1.000 and one implying more than 100% attenuation, but a run whose gravity went UP produced a NEGATIVE attenuation - which was then averaged into the headline figure and plotted as a negative bar. Verified against the live code: OG 1010 -> FG 1020 gave -100.0%. Now rejected, and reported by `implausible_runs` with the reason "the gravity went up, which is usually a mis-ordered pair of readings". Undated readings ---------------- An undated reading sorted to the front of the run, so it became the original gravity - which put the OG after the FG and produced a negative attenuation. The OG now comes from the earliest *dated* reading, and `days_to_target` skips the readings it cannot place on the timeline rather than giving up on the whole run. Verified: readings 1050 (dated), 1005 (undated), 1010 (dated) gave None instead of 24 days, and an OG of 1005 instead of 1050. Active runs on the curve ------------------------ The curve chart filtered on `curve.length > 1` only, so it plotted the active runs as well - a partial fermentation on a chart meant to describe how a completed one behaves. It now excludes them, along with the suspect runs. Four fetches, one payload ------------------------- `/api/runs` carries every reading of every run, and four charts each fetched it independently - so the analysis page made two identical round-trips of the whole collection. There is now one shared fetch. Also ---- - The "Readings that need a second look" table links to the run, so a suspect reading can be corrected in one click. - `days_to_1015` and the `curves` variable were computed and never used. Removed. - A reading below 1.000 now says what it is - "beer cannot be less dense than water, so this is almost certainly a typo (a 1.012 reading entered as 012?)". The reading is still SAVED: rejecting it would lose the brewer's actual observation, and seeing it recorded is how they spot the mistake. 142 tests (up from 134).
This commit is contained in:
+25
-1
@@ -186,11 +186,16 @@ def test_logout_clears_the_session(logged_in):
|
||||
|
||||
|
||||
def test_out_of_range_reading_is_saved_but_warned(logged_in, repo):
|
||||
"""A reading outside the range is SAVED with a warning.
|
||||
|
||||
Rejecting it would lose the brewer's actual observation, and seeing it
|
||||
recorded is how they spot and correct a typo.
|
||||
"""
|
||||
response = logged_in.post("/brews", data={
|
||||
"beer_run_id": "12",
|
||||
"beer_run_type": "Odd",
|
||||
"Date": "2026-05-01",
|
||||
"sg": "950",
|
||||
"sg": "1250",
|
||||
}, follow_redirects=True)
|
||||
assert response.status_code == 200
|
||||
assert b"outside the usual hydrometer range" in response.data
|
||||
@@ -198,6 +203,25 @@ def test_out_of_range_reading_is_saved_but_warned(logged_in, repo):
|
||||
assert repo.readings.find_one({"beer_run_id": "12"}) is not None
|
||||
|
||||
|
||||
def test_a_reading_below_water_says_it_is_always_a_typo(logged_in, repo):
|
||||
"""A gravity below 1.000 cannot be real, so the warning says so.
|
||||
|
||||
This is the run 12 case: a 1.012 reading entered as "012". The
|
||||
reading is still saved, but the message names the likely cause.
|
||||
"""
|
||||
response = logged_in.post("/brews", data={
|
||||
"beer_run_id": "13",
|
||||
"beer_run_type": "Typo",
|
||||
"Date": "2026-05-01",
|
||||
"sg": "900",
|
||||
}, follow_redirects=True)
|
||||
assert response.status_code == 200
|
||||
assert b"below 1.000" in response.data
|
||||
assert b"typo" in response.data
|
||||
# Still saved, so the mistake is visible and can be corrected.
|
||||
assert repo.readings.find_one({"beer_run_id": "13"}) is not None
|
||||
|
||||
|
||||
# ------------------------------------------------------- security: passwords #
|
||||
|
||||
def test_legacy_plaintext_password_is_accepted_and_migrated(repo):
|
||||
|
||||
Reference in New Issue
Block a user