From eb313dbab7944125d09fef9824d45a3b52c788f4 Mon Sep 17 00:00:00 2001
From: Hans Kallekleiv <16436291+HansKallekleiv@users.noreply.github.com>
Date: Tue, 20 Aug 2024 13:54:22 +0200
Subject: [PATCH] Add wellbore status and purpose filtering to wellslayer
---
.../primary/routers/well/converters.py | 2 +
.../primary/primary/routers/well/schemas.py | 3 +-
.../queries/get_wellbore_headers.py | 38 ++++-
.../primary/services/smda_access/types.py | 3 +-
frontend/src/api/models/WellboreHeader.ts | 2 +
.../modules/2DViewer/layers/WellboreLayer.ts | 6 -
.../layerSettings/wellboreLayer.tsx | 12 +-
frontend/src/modules/2DViewer/view/view.tsx | 2 +-
.../settings/components/wellboreSelector.tsx | 148 +++++++++++++-----
9 files changed, 160 insertions(+), 56 deletions(-)
diff --git a/backend_py/primary/primary/routers/well/converters.py b/backend_py/primary/primary/routers/well/converters.py
index f6d01f078..21326e94c 100644
--- a/backend_py/primary/primary/routers/well/converters.py
+++ b/backend_py/primary/primary/routers/well/converters.py
@@ -57,6 +57,8 @@ def convert_wellbore_header_to_schema(
wellNorthing=drilled_wellbore_header.well_northing,
depthReferencePoint=drilled_wellbore_header.depth_reference_point,
depthReferenceElevation=drilled_wellbore_header.depth_reference_elevation,
+ wellborePurpose=drilled_wellbore_header.wellbore_purpose,
+ wellboreStatus=drilled_wellbore_header.wellbore_status,
)
diff --git a/backend_py/primary/primary/routers/well/schemas.py b/backend_py/primary/primary/routers/well/schemas.py
index 8427292d0..a63739665 100644
--- a/backend_py/primary/primary/routers/well/schemas.py
+++ b/backend_py/primary/primary/routers/well/schemas.py
@@ -32,7 +32,8 @@ class WellboreHeader(BaseModel):
wellNorthing: float
depthReferencePoint: str
depthReferenceElevation: float
-
+ wellborePurpose: str
+ wellboreStatus: str
class WellboreTrajectory(BaseModel):
wellboreUuid: str
diff --git a/backend_py/primary/primary/services/smda_access/queries/get_wellbore_headers.py b/backend_py/primary/primary/services/smda_access/queries/get_wellbore_headers.py
index 6fd245cb0..25a4a2f98 100644
--- a/backend_py/primary/primary/services/smda_access/queries/get_wellbore_headers.py
+++ b/backend_py/primary/primary/services/smda_access/queries/get_wellbore_headers.py
@@ -1,16 +1,20 @@
from typing import List
-
+import logging
from webviz_pkg.core_utils.perf_timer import PerfTimer
from ..types import WellboreHeader
from ._get_request import get
+LOGGER = logging.getLogger(__name__)
async def get_wellbore_headers(
access_token: str,
field_identifier: str,
) -> List[WellboreHeader]:
- endpoint = "wellbore-survey-headers"
+
+ timer = PerfTimer()
+
+ survey_headers_endpoint = "wellbore-survey-headers"
projection = [
"wellbore_uuid",
"unique_wellbore_identifier",
@@ -27,7 +31,29 @@ async def get_wellbore_headers(
"field_identifier": field_identifier,
}
- timer = PerfTimer()
- result = await get(access_token=access_token, endpoint=endpoint, params=params)
- print(f"TIME SMDA fetch well headers took {timer.lap_s():.2f} seconds")
- return [WellboreHeader(**result) for result in result]
+ survey_header_results = await get(access_token=access_token, endpoint=survey_headers_endpoint, params=params)
+ LOGGER.debug(f"TIME SMDA fetch well headers took {timer.lap_s():.2f} seconds")
+
+ wellheaders_endpoint = "wellheaders"
+ projection = [
+ "unique_wellbore_identifier",
+ "wellbore_purpose",
+ "wellbore_status"
+ ]
+ params = {
+ "_projection": ",".join(projection),
+ "_sort": "unique_wellbore_identifier",
+ "field_identifier": field_identifier,
+ }
+
+ wellbore_headers_results = await get(access_token=access_token, endpoint=wellheaders_endpoint, params=params)
+
+ for survey_header in survey_header_results:
+ for wellbore_header in wellbore_headers_results:
+ if survey_header['unique_wellbore_identifier'] == wellbore_header['unique_wellbore_identifier']:
+ survey_header['wellbore_purpose'] = wellbore_header['wellbore_purpose']
+ survey_header['wellbore_status'] = wellbore_header['wellbore_status']
+ break
+
+ LOGGER.debug(f"TIME SMDA fetch well headers took {timer.lap_s():.2f} seconds")
+ return [WellboreHeader(**result) for result in survey_header_results]
diff --git a/backend_py/primary/primary/services/smda_access/types.py b/backend_py/primary/primary/services/smda_access/types.py
index fe2903e78..cb92a2d0d 100644
--- a/backend_py/primary/primary/services/smda_access/types.py
+++ b/backend_py/primary/primary/services/smda_access/types.py
@@ -41,7 +41,8 @@ class WellboreHeader(BaseModel):
well_northing: float
depth_reference_point: str
depth_reference_elevation: float
-
+ wellbore_purpose:str
+ wellbore_status:str
class StratigraphicUnit(BaseModel):
"""
diff --git a/frontend/src/api/models/WellboreHeader.ts b/frontend/src/api/models/WellboreHeader.ts
index adcabe04a..61c60bdc4 100644
--- a/frontend/src/api/models/WellboreHeader.ts
+++ b/frontend/src/api/models/WellboreHeader.ts
@@ -11,5 +11,7 @@ export type WellboreHeader = {
wellNorthing: number;
depthReferencePoint: string;
depthReferenceElevation: number;
+ wellborePurpose: string;
+ wellboreStatus: string;
};
diff --git a/frontend/src/modules/2DViewer/layers/WellboreLayer.ts b/frontend/src/modules/2DViewer/layers/WellboreLayer.ts
index 783d3cfcc..94d72e284 100644
--- a/frontend/src/modules/2DViewer/layers/WellboreLayer.ts
+++ b/frontend/src/modules/2DViewer/layers/WellboreLayer.ts
@@ -67,12 +67,6 @@ export class WellboreLayer extends BaseLayer