fix: move measuring_point_height_is_assumed from thing to measuring_p…#533
fix: move measuring_point_height_is_assumed from thing to measuring_p…#533
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds a measuring_point_height_is_assumed boolean field to the MeasuringPointHistory table to track whether a measuring point height value was explicitly provided or assumed/defaulted to 0. The changes ensure that water wells always have at least one measuring point history record, with a default value of 0 when no explicit height is provided.
Changes:
- Added
measuring_point_height_is_assumedboolean column toMeasuringPointHistorytable with database migration - Modified well creation logic to always create a
MeasuringPointHistoryrecord, defaulting to 0 when height is not provided and marking it as assumed - Updated schemas to include the new field in both request and response models
- Enhanced transfer logic to handle missing measuring point heights and track whether values are assumed
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
alembic/versions/c4d5e6f7a8b9_add_measuring_point_height_is_assumed.py |
Database migration to add the new boolean column to measuring_point_history table |
db/measuring_point_history.py |
Added measuring_point_height_is_assumed boolean field to the model |
db/thing.py |
Added guard to return 0 when measuring point history is empty; removed blank line |
schemas/thing.py |
Added measuring_point_height_is_assumed field to CreateWell and WellResponse schemas |
services/thing_helper.py |
Modified to always create MeasuringPointHistory, defaulting to 0 with is_assumed flag; added NaN handling |
services/well_inventory_csv.py |
Simplified to pass Pydantic model directly to add_thing |
transfers/well_transfer.py |
Added logic to handle missing measuring points, track assumed status, and added debugging output; included new field in exclusions list |
transfers/util.py |
Added helper method to retrieve valid values for a lexicon type |
alembic/versions/c4d5e6f7a8b9_add_measuring_point_height_is_assumed.py
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3e00163070
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…sumed.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…med height status
|
@jirhiker There are two tables that capture measuring point height: The The A NULL in the My recommendation is to keep the |
|
@ksmuczynski I agree with everything except that any measuring_point_height should be nullable. defaulting the measuring_point_height to 0 and adding flags in both the Observation and MeasuringPointHistory reduces the complexity of the logic to calculate depth to water bgs. Will you open a jira ticket for adding the observation_reason flag to Observation. |
|
@ksmuczynski I think for non legacy data and when implementing the Well Inventory/Water Level forms we should very much consider
|
|
@ksmuczynski upon further consideration Im going to pass this off to you and let you move forward with your recommendation. I will close this PR as Ive started to introduce scope creep |
|
Sure thing, I'll get a Jira ticket opened for the observation_reason field and lexicon terms today. Regarding the 0 default for the measuring point height: I’m hesitant to go that route because, in the field, a height of 0 actually describes a specific well type (flush mount). If we default to 0 during a bulk CSV upload, we'll lose the ability to distinguish between a flush mount well and a forgotten measurement. This risks introducing a small elevation error that would be invisible to anyone reviewing the data later. To keep the logic simple for reporting without losing data integrity, what if we keep the database field (Observation.measuring_point_height) Nullable but handle the 'fallback' logic in a Calculated View or a SQLAlchemy hybrid property? This creates a 'virtual' non-nullable column for the app to query, and we don't have to deal with NULL math or complex joins in the code. For our current CLI tool, we could add a Pydantic validator. The script will expect a height, but if that's missing, it will require an When we eventually move to web forms, we can have the UI auto-populate the height from the |
…oint_history
Why
This PR addresses the following problem / context:
How
Implementation summary - the following was changed / added / removed:
Notes
Any special considerations, workarounds, or follow-up work to note?