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 +
+ +
); } diff --git a/frontend/src/modules/2DViewer/view/view.tsx b/frontend/src/modules/2DViewer/view/view.tsx index f6f4bf6d8..88748d01b 100644 --- a/frontend/src/modules/2DViewer/view/view.tsx +++ b/frontend/src/modules/2DViewer/view/view.tsx @@ -154,7 +154,7 @@ export function View(props: ModuleViewProps): Re viewports: viewports, showLabel: true, }; - console.log(views); + return (
header.wellboreStatus))); + const availableWellborePurposes = Array.from( + new Set(props.wellboreHeaders.map((header) => header.wellborePurpose)) + ); + const [selectedWellboreStatuses, setSelectedWellboreStatuses] = useValidArrayState({ + initialState: availableWellboreStatuses, + validStateArray: availableWellboreStatuses, + }); + const [selectedWellborePurposes, setSelectedWellborePurposes] = useValidArrayState({ + initialState: availableWellborePurposes, + validStateArray: availableWellborePurposes, + }); + React.useEffect(() => { + props.onSelectedWellboreUuidsChange( + props.wellboreHeaders + .filter((header) => selectedWellborePurposes.includes(header.wellborePurpose)) + .filter((header) => selectedWellboreStatuses.includes(header.wellboreStatus)) + // .filter((header) => props.selectedWellboreUuids.includes(header.wellboreUuid)) + .map((header) => header.wellboreUuid) + ); + }, [selectedWellborePurposes, selectedWellboreStatuses]); + function handleSelectAll() { - props.onSelectedWellboreUuidsChange(props.wellboreHeaders.map((header) => header.wellboreUuid)); + props.onSelectedWellboreUuidsChange( + props.wellboreHeaders + .filter((header) => selectedWellborePurposes.includes(header.wellborePurpose)) + .filter((header) => selectedWellboreStatuses.includes(header.wellboreStatus)) + .map((header) => header.wellboreUuid) + ); } function handleUnselectAll() { props.onSelectedWellboreUuidsChange([]); } + function makeWellHeadersOptions(): SelectOption[] { + return props.wellboreHeaders + .filter((header) => selectedWellboreStatuses.includes(header.wellboreStatus)) + .filter((header) => selectedWellborePurposes.includes(header.wellborePurpose)) + .map((wellHeader) => ({ + label: wellHeader.uniqueWellboreIdentifier, + value: wellHeader.wellboreUuid, + })); + } + return ( -
-
- - -
- + +