- letzte Ausbesserungen bei den Piezometerdaten im Gschliefgraben
This commit is contained in:
parent
b4d7ce40b3
commit
c2f2dc1b41
2 changed files with 66 additions and 11 deletions
|
@ -51,7 +51,7 @@ def main():
|
|||
elevation_dataset.is_hidden = 0
|
||||
elevation_dataset.dataset_type = "timeseries"
|
||||
elevation_dataset.observation_type = "simple"
|
||||
elevation_dataset.value_type = "text"
|
||||
elevation_dataset.value_type = "quantity"
|
||||
pg_session.commit()
|
||||
|
||||
platform_exists: bool = pg_session.query(Platform.id).filter_by(
|
||||
|
@ -61,7 +61,7 @@ def main():
|
|||
# .filter(Platform.sta_identifier == platform_sta_identifier) \
|
||||
# .first()
|
||||
# elevation_dataset.fk_platform_id = sensor_platform.id
|
||||
|
||||
|
||||
if not platform_exists:
|
||||
sensor_platform = Platform()
|
||||
max_id = pg_session.query(func.max(Platform.id)).scalar()
|
||||
|
@ -88,7 +88,7 @@ def main():
|
|||
if sensor in data:
|
||||
create_observation(elevation_dataset, sensor, data, pg_session)
|
||||
pg_session.commit()
|
||||
|
||||
|
||||
first_elevation_observation = pg_session.query(Observation) \
|
||||
.filter(Observation.fk_dataset_id == elevation_dataset.id) \
|
||||
.order_by(asc('sampling_time_start')) \
|
||||
|
@ -105,7 +105,7 @@ def main():
|
|||
elevation_dataset.last_time = last_elevation_observation.sampling_time_start
|
||||
elevation_dataset.last_value = last_elevation_observation.value_quantity
|
||||
elevation_dataset.fk_last_observation_id = last_elevation_observation.id
|
||||
|
||||
|
||||
pg_session.commit()
|
||||
pg_session.close()
|
||||
|
||||
|
@ -115,7 +115,7 @@ def create_observation(elevation_dataset: Dataset,
|
|||
data: json,
|
||||
db_session: session):
|
||||
''' create observation in db'''
|
||||
print("Sesnor key exist in JSON data")
|
||||
# print("Sesnor key exist in JSON data")
|
||||
sensor_object = data[sensor_key]
|
||||
zeitstempel = sensor_object["zeitstempel"]
|
||||
abstich = sensor_object["abstich"]
|
||||
|
@ -141,6 +141,11 @@ def create_observation(elevation_dataset: Dataset,
|
|||
new_observation.value_quantity = abstich
|
||||
new_observation.fk_dataset_id = elevation_dataset.id
|
||||
db_session.add(new_observation)
|
||||
print(f"new observation with result time {new_observation.result_time} "
|
||||
f"for drill hole {sensor_key} succesfully imported!")
|
||||
else:
|
||||
print(f"observation with result time {existing_observation.result_time} "
|
||||
f"for drill hole {sensor_key} already exists!")
|
||||
|
||||
|
||||
def test():
|
||||
|
|
Loading…
Add table
editor.link_modal.header
Reference in a new issue