2626 amp_viewer_function ,
2727 viewer_function ,
2828)
29- from core .initializers import register_routes , init_lexicon , init_parameter
29+ from core .initializers import (
30+ register_routes ,
31+ init_lexicon ,
32+ init_parameter ,
33+ erase_and_rebuild_db ,
34+ )
3035from db import (
3136 Location ,
3237 Thing ,
3338 LocationThingAssociation ,
34- Base ,
3539 Sensor ,
3640 LexiconTerm ,
3741 Group ,
3842 GroupThingAssociation ,
3943)
40- from db .engine import session_ctx , engine
44+ from db .engine import session_ctx
4145
4246with session_ctx () as session :
4347 if session .query (LexiconTerm ).count () == 0 :
44- Base .metadata .drop_all (engine )
45- Base .metadata .create_all (engine )
48+ erase_and_rebuild_db (session )
4649
4750 init_lexicon ()
4851 init_parameter ()
@@ -67,6 +70,27 @@ def add_location(lid):
6770 return loc
6871
6972
73+ def add_spring (location , sid ):
74+ spring = well = Thing (
75+ name = f"SP-{ sid :04d} " ,
76+ first_visit_date = "2023-03-03" ,
77+ thing_type = "spring" ,
78+ release_status = "draft" ,
79+ # well_depth=10,
80+ # hole_depth=10,
81+ # well_construction_notes="Test well construction notes",
82+ # well_casing_diameter=5.0,
83+ # well_casing_depth=10.0,
84+ )
85+ session .add (spring )
86+ session .commit ()
87+
88+ assoc = LocationThingAssociation (location = location , thing = well )
89+ assoc .effective_start = "2025-02-01T00:00:00Z"
90+ session .add (assoc )
91+ session .commit ()
92+
93+
7094def add_well (location , wid ):
7195 well = session .get (Thing , wid )
7296 if not well :
@@ -95,10 +119,12 @@ def add_well(location, wid):
95119 loc = add_location (1 )
96120 loc2 = add_location (2 )
97121 loc3 = add_location (3 )
122+ loc4 = add_location (4 )
98123
99124 water_well = add_well (loc , 1 )
100125 water_well2 = add_well (loc2 , 2 )
101126 water_well3 = add_well (loc3 , 3 )
127+ spring = add_spring (loc4 , 4 )
102128
103129 sensor = session .get (Sensor , 1 )
104130 if not sensor :
0 commit comments