|
7 | 7 |
|
8 | 8 | from primary.services.sumo_access.case_inspector import CaseInspector
|
9 | 9 | from primary.services.sumo_access.surface_access import SurfaceAccess
|
10 |
| -from primary.services.smda_access.stratigraphy_access import StratigraphyAccess, StratigraphicUnit |
| 10 | +from primary.services.smda_access import SmdaAccess, StratigraphicUnit |
11 | 11 | from primary.services.smda_access.stratigraphy_utils import sort_stratigraphic_names_by_hierarchy
|
12 |
| -from primary.services.smda_access.mocked_drogon_smda_access import _mocked_stratigraphy_access |
| 12 | +from primary.services.smda_access.drogon import DrogonSmdaAccess |
13 | 13 | from primary.services.utils.statistic_function import StatisticFunction
|
14 | 14 | from primary.services.utils.surface_intersect_with_polyline import intersect_surface_with_polyline
|
15 | 15 | from primary.services.utils.authenticated_user import AuthenticatedUser
|
@@ -295,22 +295,41 @@ async def get_misfit_surface_data(
|
295 | 295 | raise HTTPException(status.HTTP_501_NOT_IMPLEMENTED)
|
296 | 296 |
|
297 | 297 |
|
| 298 | +@router.get("/stratigraphic_units") |
| 299 | +async def get_stratigraphic_units( |
| 300 | + # fmt:off |
| 301 | + response: Response, |
| 302 | + authenticated_user: Annotated[AuthenticatedUser, Depends(AuthHelper.get_authenticated_user)], |
| 303 | + case_uuid: Annotated[str, Query(description="Sumo case uuid")], |
| 304 | + # fmt:on |
| 305 | +) -> list[schemas.StratigraphicUnit]: |
| 306 | + perf_metrics = ResponsePerfMetrics(response) |
| 307 | + |
| 308 | + strat_units = await _get_stratigraphic_units_for_case_async(authenticated_user, case_uuid) |
| 309 | + api_strat_units = [converters.to_api_stratigraphic_unit(strat_unit) for strat_unit in strat_units] |
| 310 | + |
| 311 | + LOGGER.info(f"Got stratigraphic units in: {perf_metrics.to_string()}") |
| 312 | + |
| 313 | + return api_strat_units |
| 314 | + |
| 315 | + |
298 | 316 | async def _get_stratigraphic_units_for_case_async(
|
299 | 317 | authenticated_user: AuthenticatedUser, case_uuid: str
|
300 | 318 | ) -> list[StratigraphicUnit]:
|
301 | 319 | perf_metrics = PerfMetrics()
|
302 | 320 |
|
303 | 321 | case_inspector = CaseInspector.from_case_uuid(authenticated_user.get_sumo_access_token(), case_uuid)
|
| 322 | + field_identifiers = await case_inspector.get_field_identifiers_async() |
304 | 323 | strat_column_identifier = await case_inspector.get_stratigraphic_column_identifier_async()
|
305 | 324 | perf_metrics.record_lap("get-strat-ident")
|
306 | 325 |
|
307 |
| - strat_access: StratigraphyAccess | _mocked_stratigraphy_access.StratigraphyAccess |
| 326 | + smda_access: SmdaAccess | DrogonSmdaAccess |
308 | 327 | if strat_column_identifier == "DROGON_HAS_NO_STRATCOLUMN":
|
309 |
| - strat_access = _mocked_stratigraphy_access.StratigraphyAccess(authenticated_user.get_smda_access_token()) |
| 328 | + smda_access = DrogonSmdaAccess() |
310 | 329 | else:
|
311 |
| - strat_access = StratigraphyAccess(authenticated_user.get_smda_access_token()) |
| 330 | + smda_access = SmdaAccess(authenticated_user.get_smda_access_token(), field_identifier=field_identifiers[0]) |
312 | 331 |
|
313 |
| - strat_units = await strat_access.get_stratigraphic_units(strat_column_identifier) |
| 332 | + strat_units = await smda_access.get_stratigraphic_units(strat_column_identifier) |
314 | 333 | perf_metrics.record_lap("get-strat-units")
|
315 | 334 |
|
316 | 335 | LOGGER.info(f"Got stratigraphic units for case in : {perf_metrics.to_string()}")
|
|
0 commit comments