Skip to content

Keep the borewell's own water level when a later reading is added - #82

Merged
Mehulsri07 merged 3 commits into
mainfrom
keep-first-water-level
Oct 14, 2026
Merged

Mehulsri07 merged 3 commits into
mainfrom
keep-first-water-level

Conversation

@Mehulsri07

Copy link
Copy Markdown
Owner

Adding the first water reading to a borewell overwrote the water level recorded with it (form or Excel entries keep it only on the borewell row), so a change over time at the same borewell could never be seen. StrataVision's rate-of-change map needs that.

  • add_water_reading: when the borewell has no readings yet but has a water level and a date, that level (and dynamic level) is saved as its first reading, dated with the borewell's date, in the same transaction. Skipped if the new reading has the same date.
  • Migration 5 (schema 4 → 5): does the same once for existing borewells with a level and date but no readings. Idempotent (NOT EXISTS). Opening the database makes the usual upgrade backup first.
  • Tests: first later reading keeps the old level and the current level follows the newest; second reading doesn't duplicate; same-date case; migration with/without readings and with no level, plus re-running it. The existing water-reading test now uses dates after the drilling date.
  • CHANGELOG Unreleased entry.

Checks: cargo test (strata_db), clippy -D warnings, typecheck, eslint on app/core/e2e/scripts, npm test all pass.

Note for StrataVision: after a release it must take the new schema (version 5), since an older build refuses a newer database.

…dded

Adding a water reading made the newest reading the borewell's current level,
so the level recorded with the borewell (form or Excel) was overwritten and
the first comparison over time was lost. add_water_reading now saves that
level as the first reading (dated with the borewell's date) before adding
the new one, unless the new reading is on the same date. Migration 5 does
the same once for borewells already saved with no readings.
The e2e reading was dated before the borewell's own date (today), so the
kept drilling-time level was rightly the newest. Date it next year and
check both levels are kept. Bump rustls for RUSTSEC-2026-0346..0349,
published today.
A reading dated next year moved the map's three-year window. Accept any
year in the map's 'readings since' note so a run on 31 December passes.
@Mehulsri07
Mehulsri07 enabled auto-merge October 14, 2026 16:45
@Mehulsri07
Mehulsri07 merged commit 8ff0a06 into main Oct 14, 2026
7 checks passed
@Mehulsri07
Mehulsri07 deleted the keep-first-water-level branch October 14, 2026 16:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant