Skip to content

Commit 3461516

Browse files
committed
fix: add measuring_point_height_is_assumed property to determine assumed height status
1 parent e3a304b commit 3461516

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

db/thing.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,23 @@ def measuring_point_description(self) -> str | None:
519519
else:
520520
return None
521521

522+
@property
523+
def measuring_point_height_is_assumed(self) -> bool | None:
524+
"""
525+
Returns whether the most recent measuring point height is assumed.
526+
527+
Since measuring_point_history is eagerly loaded, this should not introduce N+1 query issues.
528+
"""
529+
if self.thing_type == "water well":
530+
sorted_measuring_point_history = sorted(
531+
self.measuring_points, key=lambda x: x.start_date, reverse=True
532+
)
533+
if not sorted_measuring_point_history:
534+
return True
535+
return sorted_measuring_point_history[0].measuring_point_height_is_assumed
536+
else:
537+
return None
538+
522539
@property
523540
def well_depth_source(self) -> str | None:
524541
return self._get_data_provenance_attribute("well_depth", "origin_type")

schemas/thing.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,6 @@ class CreateWell(CreateBaseThing, ValidateWell):
148148
measuring_point_height: float | None = Field(
149149
default=0, description="Measuring point height in feet"
150150
)
151-
measuring_point_height_is_assumed: bool = False
152151
measuring_point_description: str | None = None
153152
well_completion_date: PastOrTodayDate | None = None
154153
well_completion_date_source: str | None = None

0 commit comments

Comments
 (0)