Skip to content

Commit

Permalink
Adjustments according to review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenthoms committed Aug 19, 2024
1 parent 06065d1 commit f823a97
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 54 deletions.
35 changes: 2 additions & 33 deletions frontend/src/modules/3DViewer/view/atoms/derivedAtoms.ts
Original file line number Diff line number Diff line change
@@ -1,42 +1,11 @@
import { IntersectionReferenceSystem } from "@equinor/esv-intersection";
import { apiService } from "@framework/ApiService";
import { EnsembleSetAtom } from "@framework/GlobalAtoms";
import { IntersectionType } from "@framework/types/intersection";
import { IntersectionPolylinesAtom } from "@framework/userCreatedItems/IntersectionPolylines";

import { atom } from "jotai";
import { atomWithQuery } from "jotai-tanstack-query";

import {
customIntersectionPolylineIdAtom,
ensembleIdentAtom,
highlightedWellboreUuidAtom,
intersectionTypeAtom,
} from "./baseAtoms";

const STALE_TIME = 60 * 1000;
const CACHE_TIME = 60 * 1000;

export const fieldWellboreTrajectoriesQueryAtom = atomWithQuery((get) => {
const ensembleIdent = get(ensembleIdentAtom);
const ensembleSet = get(EnsembleSetAtom);

let fieldIdentifier: string | null = null;
if (ensembleIdent) {
const ensemble = ensembleSet.findEnsemble(ensembleIdent);
if (ensemble) {
fieldIdentifier = ensemble.getFieldIdentifier();
}
}

return {
queryKey: ["getFieldWellboreTrajectories", fieldIdentifier ?? ""],
queryFn: () => apiService.well.getFieldWellTrajectories(fieldIdentifier ?? ""),
staleTime: STALE_TIME,
gcTime: CACHE_TIME,
enabled: Boolean(fieldIdentifier),
};
});
import { customIntersectionPolylineIdAtom, highlightedWellboreUuidAtom, intersectionTypeAtom } from "./baseAtoms";
import { fieldWellboreTrajectoriesQueryAtom } from "./queryAtoms";

export const intersectionReferenceSystemAtom = atom((get) => {
const fieldWellboreTrajectories = get(fieldWellboreTrajectoriesQueryAtom);
Expand Down
30 changes: 30 additions & 0 deletions frontend/src/modules/3DViewer/view/atoms/queryAtoms.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { apiService } from "@framework/ApiService";
import { EnsembleSetAtom } from "@framework/GlobalAtoms";

import { atomWithQuery } from "jotai-tanstack-query";

import { ensembleIdentAtom } from "./baseAtoms";

const STALE_TIME = 60 * 1000;
const CACHE_TIME = 60 * 1000;

export const fieldWellboreTrajectoriesQueryAtom = atomWithQuery((get) => {
const ensembleIdent = get(ensembleIdentAtom);
const ensembleSet = get(EnsembleSetAtom);

let fieldIdentifier: string | null = null;
if (ensembleIdent) {
const ensemble = ensembleSet.findEnsemble(ensembleIdent);
if (ensemble) {
fieldIdentifier = ensemble.getFieldIdentifier();
}
}

return {
queryKey: ["getFieldWellboreTrajectories", fieldIdentifier ?? ""],
queryFn: () => apiService.well.getFieldWellTrajectories(fieldIdentifier ?? ""),
staleTime: STALE_TIME,
gcTime: CACHE_TIME,
enabled: Boolean(fieldIdentifier),
};
});
21 changes: 1 addition & 20 deletions frontend/src/modules/Intersection/view/atoms/derivedAtoms.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,18 @@
import { WellboreTrajectory_api } from "@api";
import { IntersectionReferenceSystem } from "@equinor/esv-intersection";
import { apiService } from "@framework/ApiService";
import { IntersectionType } from "@framework/types/intersection";
import { IntersectionPolylinesAtom } from "@framework/userCreatedItems/IntersectionPolylines";
import { point2Distance, vec2FromArray } from "@lib/utils/vec2";
import { CURVE_FITTING_EPSILON } from "@modules/Intersection/typesAndEnums";
import { calcExtendedSimplifiedWellboreTrajectoryInXYPlane } from "@modules/_shared/utils/wellbore";

import { atom } from "jotai";
import { atomWithQuery } from "jotai-tanstack-query";

import {
intersectionExtensionLengthAtom,
intersectionTypeAtom,
selectedCustomIntersectionPolylineIdAtom,
wellboreHeaderAtom,
} from "./baseAtoms";

const STALE_TIME = 60 * 1000;
const CACHE_TIME = 60 * 1000;
import { wellboreTrajectoryQueryAtom } from "./queryAtoms";

export const selectedCustomIntersectionPolylineAtom = atom((get) => {
const customIntersectionPolylineId = get(selectedCustomIntersectionPolylineIdAtom);
Expand All @@ -27,19 +21,6 @@ export const selectedCustomIntersectionPolylineAtom = atom((get) => {
return customIntersectionPolylines.find((el) => el.id === customIntersectionPolylineId);
});

export const wellboreTrajectoryQueryAtom = atomWithQuery((get) => {
const wellbore = get(wellboreHeaderAtom);

return {
queryKey: ["getWellboreTrajectory", wellbore?.uuid ?? ""],
queryFn: () => apiService.well.getWellTrajectories(wellbore?.uuid ? [wellbore.uuid] : []),
staleTime: STALE_TIME,
gcTime: CACHE_TIME,
select: (data: WellboreTrajectory_api[]) => data[0],
enabled: wellbore?.uuid ? true : false,
};
});

export const intersectionReferenceSystemAtom = atom((get) => {
const wellboreTrajectoryQuery = get(wellboreTrajectoryQueryAtom);
const customIntersectionPolyline = get(selectedCustomIntersectionPolylineAtom);
Expand Down
22 changes: 22 additions & 0 deletions frontend/src/modules/Intersection/view/atoms/queryAtoms.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { WellboreTrajectory_api } from "@api";
import { apiService } from "@framework/ApiService";

import { atomWithQuery } from "jotai-tanstack-query";

import { wellboreHeaderAtom } from "./baseAtoms";

const STALE_TIME = 60 * 1000;
const CACHE_TIME = 60 * 1000;

export const wellboreTrajectoryQueryAtom = atomWithQuery((get) => {
const wellbore = get(wellboreHeaderAtom);

return {
queryKey: ["getWellboreTrajectory", wellbore?.uuid ?? ""],
queryFn: () => apiService.well.getWellTrajectories(wellbore?.uuid ? [wellbore.uuid] : []),
staleTime: STALE_TIME,
gcTime: CACHE_TIME,
select: (data: WellboreTrajectory_api[]) => data[0],
enabled: wellbore?.uuid ? true : false,
};
});
3 changes: 2 additions & 1 deletion frontend/src/modules/Intersection/view/view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import { resolveClassNames } from "@lib/utils/resolveClassNames";

import { useAtomValue } from "jotai";

import { intersectionReferenceSystemAtom, polylineAtom, wellboreTrajectoryQueryAtom } from "./atoms/derivedAtoms";
import { intersectionReferenceSystemAtom, polylineAtom } from "./atoms/derivedAtoms";
import { wellboreTrajectoryQueryAtom } from "./atoms/queryAtoms";
import { LayersWrapper } from "./components/layersWrapper";
import { useWellboreCasingsQuery } from "./queries/wellboreSchematicsQueries";

Expand Down

0 comments on commit f823a97

Please sign in to comment.