Skip to content

Commit bbfa939

Browse files
committed
feat: add datalogger/open status to well transfer & fix exclusions
These fields are in the status history table, not the thing table. the same fields should be excluded from both sequence and paralell transfers
1 parent 8633977 commit bbfa939

1 file changed

Lines changed: 35 additions & 5 deletions

File tree

transfers/well_transfer.py

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -650,10 +650,6 @@ def _build_well_payload(self, row) -> CreateWell | None:
650650
[],
651651
)
652652

653-
is_suitable_for_datalogger = (
654-
bool(row.OpenWellLoggerOK) if notna(row.OpenWellLoggerOK) else False
655-
)
656-
657653
mpheight = row.MPHeight
658654
mpheight_description = row.MeasuringPoint
659655
if mpheight is None:
@@ -689,7 +685,6 @@ def _build_well_payload(self, row) -> CreateWell | None:
689685
well_driller_name=row.DrillerName,
690686
well_construction_method=wcm,
691687
well_pump_type=well_pump_type,
692-
is_suitable_for_datalogger=is_suitable_for_datalogger,
693688
)
694689

695690
CreateWell.model_validate(data)
@@ -722,6 +717,15 @@ def _persist_well(
722717
"measuring_point_description",
723718
"well_completion_date_source",
724719
"well_construction_method_source",
720+
"well_depth_source",
721+
"alternate_ids",
722+
"monitoring_frequencies",
723+
"notes",
724+
"well_depth_source",
725+
"well_completion_date_source",
726+
"well_construction_method_source",
727+
"is_suitable_for_datalogger",
728+
"is_open",
725729
]
726730
)
727731
well_data["thing_type"] = "water well"
@@ -882,6 +886,32 @@ def _add_histories(self, session: Session, row, well: Thing) -> None:
882886
except KeyError:
883887
pass
884888

889+
if notna(row.OpenWellLoggerOK):
890+
if bool(row.OpenWellLoggerOK):
891+
status_value = "Datalogger can be installed"
892+
else:
893+
status_value = "Datalogger cannot be installed"
894+
status_history = StatusHistory(
895+
status_type="Datalogger Suitability Status",
896+
status_value=status_value,
897+
reason=None,
898+
start_date=datetime.now(tz=UTC),
899+
target_id=target_id,
900+
target_table=target_table,
901+
)
902+
session.add(status_history)
903+
904+
if notna(row.CurrentUse) and "A" in row.CurrentUse:
905+
status_history = StatusHistory(
906+
status_type="Open Status",
907+
status_value="Open",
908+
reason=None,
909+
start_date=datetime.now(tz=UTC),
910+
target_id=target_id,
911+
target_table=target_table,
912+
)
913+
session.add(status_history)
914+
885915
def _step_parallel_complete(
886916
self,
887917
session: Session,

0 commit comments

Comments
 (0)