Skip to content

Commit f1f81ad

Browse files
authored
Merge pull request #117 from DataIntegrationGroup/jab-release-status-sample-schema-fixes
NO TICKET: near-universal adoption of `release_status` and `created_at` | complete implementation of `active_location` for the `/thing` router | async coverage for all endpoints
2 parents 26ede4d + 6b70cea commit f1f81ad

35 files changed

Lines changed: 565 additions & 237 deletions

api/contact.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ def database_error_handler(
119119
summary="Create a new contact",
120120
status_code=status.HTTP_201_CREATED,
121121
)
122-
def create_contact(
122+
async def create_contact(
123123
contact_data: CreateContact, session: session_dependency, user: amp_admin_dependency
124124
) -> ContactResponse:
125125
try:
@@ -133,7 +133,7 @@ def create_contact(
133133
summary="Add an address to a contact",
134134
status_code=status.HTTP_201_CREATED,
135135
)
136-
def create_address(
136+
async def create_address(
137137
address_data: CreateAddress,
138138
session: session_dependency,
139139
user: amp_admin_dependency,
@@ -156,7 +156,7 @@ def create_address(
156156
summary="Add an email to a contact",
157157
status_code=status.HTTP_201_CREATED,
158158
)
159-
def create_email(
159+
async def create_email(
160160
email_data: CreateEmail,
161161
session: session_dependency,
162162
user: amp_admin_dependency,
@@ -172,7 +172,7 @@ def create_email(
172172
summary="Add a phone number to a contact",
173173
status_code=status.HTTP_201_CREATED,
174174
)
175-
def create_phone(
175+
async def create_phone(
176176
phone_data: CreatePhone,
177177
session: session_dependency,
178178
user: amp_admin_dependency,
@@ -211,7 +211,7 @@ def create_phone(
211211
@router.patch(
212212
"/email/{email_id}",
213213
)
214-
def update_contact_email(
214+
async def update_contact_email(
215215
email_id: int,
216216
email_data: UpdateEmail,
217217
session: session_dependency,
@@ -226,7 +226,7 @@ def update_contact_email(
226226
@router.patch(
227227
"/phone/{phone_id}",
228228
)
229-
def update_contact_phone(
229+
async def update_contact_phone(
230230
phone_id: int,
231231
phone_data: UpdatePhone,
232232
session: session_dependency,
@@ -246,7 +246,7 @@ def update_contact_phone(
246246
@router.patch(
247247
"/address/{address_id}",
248248
)
249-
def update_contact_address(
249+
async def update_contact_address(
250250
address_id: int,
251251
address_data: UpdateAddress,
252252
session: session_dependency,
@@ -294,7 +294,7 @@ def update_contact_address(
294294

295295

296296
@router.patch("/{contact_id}", summary="Update contact")
297-
def update_contact(
297+
async def update_contact(
298298
contact_id: int,
299299
contact_data: UpdateContact,
300300
session: session_dependency,
@@ -497,7 +497,7 @@ async def get_contact_addresses(
497497

498498

499499
@router.delete("/email/{email_id}", summary="Delete contact email")
500-
def delete_contact_email(
500+
async def delete_contact_email(
501501
email_id: int, session: session_dependency, user: amp_admin_dependency
502502
):
503503
"""
@@ -507,7 +507,7 @@ def delete_contact_email(
507507

508508

509509
@router.delete("/phone/{phone_id}", summary="Delete contact phone")
510-
def delete_contact_phone(
510+
async def delete_contact_phone(
511511
phone_id: int, session: session_dependency, user: amp_admin_dependency
512512
):
513513
"""
@@ -517,7 +517,7 @@ def delete_contact_phone(
517517

518518

519519
@router.delete("/address/{address_id}", summary="Delete contact address")
520-
def delete_contact_address(
520+
async def delete_contact_address(
521521
address_id: int, session: session_dependency, user: amp_admin_dependency
522522
):
523523
"""
@@ -542,7 +542,7 @@ def delete_contact_address(
542542

543543

544544
@router.delete("/{contact_id}", summary="Delete contact")
545-
def delete_contact(
545+
async def delete_contact(
546546
contact_id: int, session: session_dependency, user: amp_admin_dependency
547547
):
548548
"""

api/group.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040

4141

4242
@router.post("", summary="Create a new group", status_code=HTTP_201_CREATED)
43-
def create_group(
43+
async def create_group(
4444
group_data: CreateGroup, session: session_dependency, user: admin_dependency
4545
) -> GroupResponse:
4646
"""

api/lexicon.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def database_error_handler(
102102
"/category",
103103
status_code=HTTP_201_CREATED,
104104
)
105-
def add_category(
105+
async def add_category(
106106
category_data: CreateLexiconCategory,
107107
session: session_dependency,
108108
user: admin_dependency,
@@ -118,7 +118,7 @@ def add_category(
118118
summary="Add term",
119119
status_code=HTTP_201_CREATED,
120120
)
121-
def add_term(
121+
async def add_term(
122122
term_data: CreateLexiconTerm, session: session_dependency, user: admin_dependency
123123
) -> LexiconTermResponse:
124124
"""
@@ -135,7 +135,7 @@ def add_term(
135135
summary="Add triple",
136136
status_code=HTTP_201_CREATED,
137137
)
138-
def add_triple(
138+
async def add_triple(
139139
triple_data: CreateLexiconTriple,
140140
session: session_dependency,
141141
user: admin_dependency,
@@ -151,7 +151,7 @@ def add_triple(
151151

152152

153153
@router.patch("/term/{term_id}", status_code=HTTP_200_OK)
154-
def update_lexicon_term(
154+
async def update_lexicon_term(
155155
term_id: int,
156156
term_data: UpdateLexiconTerm,
157157
session: session_dependency,
@@ -162,7 +162,7 @@ def update_lexicon_term(
162162

163163

164164
@router.patch("/category/{category_id}", status_code=HTTP_200_OK)
165-
def update_lexicon_category(
165+
async def update_lexicon_category(
166166
category_id: int,
167167
category_data: UpdateLexiconCategory,
168168
session: session_dependency,
@@ -174,7 +174,7 @@ def update_lexicon_category(
174174

175175

176176
@router.patch("/triple/{triple_id}", status_code=HTTP_200_OK)
177-
def update_lexicon_triple(
177+
async def update_lexicon_triple(
178178
triple_id: int,
179179
triple_data: UpdateLexiconTriple,
180180
session: session_dependency,
@@ -190,7 +190,7 @@ def update_lexicon_triple(
190190

191191

192192
@router.get("/term", summary="Get lexicon terms", status_code=HTTP_200_OK)
193-
def get_lexicon_terms(
193+
async def get_lexicon_terms(
194194
session: session_dependency,
195195
category: str | None = None,
196196
term: str | None = None,
@@ -226,12 +226,14 @@ def get_lexicon_terms(
226226

227227

228228
@router.get("/term/{term_id}", status_code=HTTP_200_OK)
229-
def get_lexicon_term(term_id: int, session: session_dependency) -> LexiconTermResponse:
229+
async def get_lexicon_term(
230+
term_id: int, session: session_dependency
231+
) -> LexiconTermResponse:
230232
return simple_get_by_id(session, LexiconTerm, term_id)
231233

232234

233235
@router.get("/category")
234-
def get_lexicon_categories(
236+
async def get_lexicon_categories(
235237
session: session_dependency,
236238
sort: str = "name",
237239
order: str = "asc",
@@ -244,7 +246,7 @@ def get_lexicon_categories(
244246

245247

246248
@router.get("/category/{category_id}")
247-
def get_lexicon_category(
249+
async def get_lexicon_category(
248250
category_id: int, session: session_dependency
249251
) -> LexiconCategoryResponse:
250252
return simple_get_by_id(session, LexiconCategory, category_id)

api/location.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
summary="Create a new sample location",
4343
status_code=status.HTTP_201_CREATED,
4444
)
45-
def create_location(
45+
async def create_location(
4646
location_data: CreateLocation, session: session_dependency, user: admin_dependency
4747
) -> LocationResponse:
4848
"""
@@ -55,7 +55,7 @@ def create_location(
5555
"/{location_id}",
5656
summary="Update a location",
5757
)
58-
def update_location(
58+
async def update_location(
5959
location_id: int,
6060
location_data: UpdateLocation,
6161
session: session_dependency,

api/observation.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151

5252
# ============= Post =============================================
5353
@router.post("/groundwater-level", status_code=HTTP_201_CREATED)
54-
def add_groundwater_level_observation(
54+
async def add_groundwater_level_observation(
5555
obs_data: CreateGroundwaterLevelObservation,
5656
session: session_dependency,
5757
user: amp_admin_dependency,
@@ -63,7 +63,7 @@ def add_groundwater_level_observation(
6363

6464

6565
@router.post("/water-chemistry", status_code=HTTP_201_CREATED)
66-
def add_water_chemistry_observation(
66+
async def add_water_chemistry_observation(
6767
obs_data: CreateWaterChemistryObservation,
6868
session: session_dependency,
6969
user: amp_admin_dependency,
@@ -76,7 +76,7 @@ def add_water_chemistry_observation(
7676

7777

7878
@router.post("/geothermal", status_code=HTTP_201_CREATED)
79-
def add_geothermal_observation(
79+
async def add_geothermal_observation(
8080
obs_data: CreateGeothermalObservation,
8181
session: session_dependency,
8282
user: admin_dependency,
@@ -92,7 +92,7 @@ def add_geothermal_observation(
9292

9393

9494
@router.patch("/groundwater-level/{observation_id}", status_code=HTTP_200_OK)
95-
def update_groundwater_level_observation(
95+
async def update_groundwater_level_observation(
9696
observation_id: int,
9797
obs_data: UpdateGroundwaterLevelObservation,
9898
session: session_dependency,
@@ -106,7 +106,7 @@ def update_groundwater_level_observation(
106106

107107

108108
@router.patch("/water-chemistry/{observation_id}", status_code=HTTP_200_OK)
109-
def update_water_chemistry_observation(
109+
async def update_water_chemistry_observation(
110110
observation_id: int,
111111
obs_data: UpdateWaterChemistryObservation,
112112
session: session_dependency,
@@ -120,7 +120,7 @@ def update_water_chemistry_observation(
120120

121121

122122
@router.patch("/geothermal/{observation_id}", status_code=HTTP_200_OK)
123-
def update_geothermal_observation(
123+
async def update_geothermal_observation(
124124
observation_id: int,
125125
obs_data: UpdateGeothermalObservation,
126126
session: session_dependency,
@@ -137,7 +137,7 @@ def update_geothermal_observation(
137137

138138

139139
@router.get("/groundwater-level", summary="Get groundwater level observations")
140-
def get_groundwater_level_observations(
140+
async def get_groundwater_level_observations(
141141
request: Request,
142142
session: session_dependency,
143143
user: amp_viewer_dependency,
@@ -171,7 +171,7 @@ def get_groundwater_level_observations(
171171
"/groundwater-level/{observation_id}",
172172
summary="Get groundwater level observation by ID",
173173
)
174-
def get_groundwater_level_observation_by_id(
174+
async def get_groundwater_level_observation_by_id(
175175
session: session_dependency,
176176
request: Request,
177177
user: amp_viewer_dependency,
@@ -185,7 +185,7 @@ def get_groundwater_level_observation_by_id(
185185

186186

187187
@router.get("/water-chemistry", summary="Get water chemistry observations")
188-
def get_water_chemistry_observations(
188+
async def get_water_chemistry_observations(
189189
request: Request,
190190
session: session_dependency,
191191
user: amp_viewer_dependency,
@@ -218,7 +218,7 @@ def get_water_chemistry_observations(
218218
@router.get(
219219
"/water-chemistry/{observation_id}", summary="Get water chemistry observation by ID"
220220
)
221-
def get_water_chemistry_observation_by_id(
221+
async def get_water_chemistry_observation_by_id(
222222
session: session_dependency,
223223
request: Request,
224224
user: amp_viewer_dependency,
@@ -232,7 +232,7 @@ def get_water_chemistry_observation_by_id(
232232

233233

234234
@router.get("/geothermal", summary="Get geothermal observations")
235-
def get_geothermal_observations(
235+
async def get_geothermal_observations(
236236
request: Request,
237237
session: session_dependency,
238238
user: viewer_dependency,
@@ -263,7 +263,7 @@ def get_geothermal_observations(
263263

264264

265265
@router.get("/geothermal/{observation_id}", summary="Get geothermal observation by ID")
266-
def get_geothermal_observation_by_id(
266+
async def get_geothermal_observation_by_id(
267267
session: session_dependency,
268268
request: Request,
269269
user: amp_viewer_dependency,
@@ -275,7 +275,7 @@ def get_geothermal_observation_by_id(
275275

276276

277277
@router.get("", summary="Get all observations")
278-
def get_all_observations(
278+
async def get_all_observations(
279279
request: Request,
280280
session: session_dependency,
281281
user: amp_viewer_dependency,
@@ -303,7 +303,7 @@ def get_all_observations(
303303

304304

305305
@router.get("/{observation_id}", summary="Get an observation by its ID")
306-
def get_observation_by_id(
306+
async def get_observation_by_id(
307307
session: session_dependency, user: amp_viewer_dependency, observation_id: int
308308
) -> ObservationResponse:
309309
return simple_get_by_id(session, Observation, observation_id)
@@ -317,7 +317,7 @@ def get_observation_by_id(
317317
summary="Delete an observation",
318318
status_code=HTTP_204_NO_CONTENT,
319319
)
320-
def delete_observation(
320+
async def delete_observation(
321321
session: session_dependency, user: amp_admin_dependency, observation_id: int
322322
) -> None:
323323
return model_deleter(session, Observation, observation_id)

0 commit comments

Comments
 (0)