From 78cb421ef338d3e9eee61e816e94462a4aa14387 Mon Sep 17 00:00:00 2001 From: jorgenherje Date: Wed, 18 Dec 2024 14:21:32 +0100 Subject: [PATCH] Encode/decode realization array for endpoints --- .../routers/inplace_volumetrics/router.py | 27 ++++++++++--------- .../primary/primary/routers/rft/router.py | 7 ++++- .../primary/primary/routers/surface/router.py | 2 +- .../primary/routers/timeseries/router.py | 18 +++++++++---- .../api/services/InplaceVolumetricsService.ts | 12 ++++----- frontend/src/api/services/RftService.ts | 6 ++--- frontend/src/api/services/SurfaceService.ts | 6 ++--- .../src/api/services/TimeseriesService.ts | 12 ++++----- .../view/atoms/queryAtoms.ts | 13 ++++++--- .../queryHooks.tsx | 6 +++-- .../_shared/InplaceVolumetrics/queryHooks.ts | 15 ++++++----- 11 files changed, 75 insertions(+), 49 deletions(-) diff --git a/backend_py/primary/primary/routers/inplace_volumetrics/router.py b/backend_py/primary/primary/routers/inplace_volumetrics/router.py index fd4879b87..8ce5d603d 100644 --- a/backend_py/primary/primary/routers/inplace_volumetrics/router.py +++ b/backend_py/primary/primary/routers/inplace_volumetrics/router.py @@ -10,6 +10,7 @@ from primary.services.utils.authenticated_user import AuthenticatedUser from primary.auth.auth_helper import AuthHelper from primary.utils.response_perf_metrics import ResponsePerfMetrics +from primary.utils.query_string_utils import decode_uint_list_str from . import schemas from . import converters @@ -52,12 +53,7 @@ async def post_get_aggregated_per_realization_table_data( group_by_identifiers: Annotated[ list[schemas.InplaceVolumetricsIdentifier] | None, Query(description="The identifiers to group table data by") ] = None, - realizations: Annotated[ - list[int] | None, - Query( - description="Optional list of realizations to include. If not specified, all realizations will be returned." - ), - ] = None, + realizations_encoded_as_uint_list_str: Annotated[str | None, Query(description="Optional list of realizations encoded as string to include. If not specified, all realizations will be included.")] = None, ) -> schemas.InplaceVolumetricTableDataPerFluidSelection: """ Get aggregated volumetric data for a given table with data per realization based on requested results and categories/index filter. @@ -67,6 +63,12 @@ async def post_get_aggregated_per_realization_table_data( """ perf_metrics = ResponsePerfMetrics(response) + realizations = None + if realizations_encoded_as_uint_list_str: + realizations = decode_uint_list_str(realizations_encoded_as_uint_list_str) + + perf_metrics.record_lap("decode realizations array") + access = await InplaceVolumetricsAccess.from_case_uuid_async( authenticated_user.get_sumo_access_token(), case_uuid, ensemble_name ) @@ -110,12 +112,7 @@ async def post_get_aggregated_statistical_table_data( group_by_identifiers: Annotated[ list[schemas.InplaceVolumetricsIdentifier] | None, Query(description="The identifiers to group table data by") ] = None, - realizations: Annotated[ - list[int] | None, - Query( - description="Optional list of realizations to include. If not specified, all realizations will be returned." - ), - ] = None, + realizations_encoded_as_uint_list_str: Annotated[str | None, Query(description="Optional list of realizations encoded as string to include. If not specified, all realizations will be included.")] = None, ) -> schemas.InplaceStatisticalVolumetricTableDataPerFluidSelection: """ Get statistical volumetric data across selected realizations for a given table based on requested results and categories/index filter. @@ -125,6 +122,12 @@ async def post_get_aggregated_statistical_table_data( """ perf_metrics = ResponsePerfMetrics(response) + realizations: list[int]|None = None + if realizations_encoded_as_uint_list_str: + realizations = decode_uint_list_str(realizations_encoded_as_uint_list_str) + + perf_metrics.record_lap("decode realizations array") + access = await InplaceVolumetricsAccess.from_case_uuid_async( authenticated_user.get_sumo_access_token(), case_uuid, ensemble_name ) diff --git a/backend_py/primary/primary/routers/rft/router.py b/backend_py/primary/primary/routers/rft/router.py index 905851df6..ee8ec2a52 100644 --- a/backend_py/primary/primary/routers/rft/router.py +++ b/backend_py/primary/primary/routers/rft/router.py @@ -6,6 +6,7 @@ from primary.auth.auth_helper import AuthHelper from primary.services.sumo_access.rft_access import RftAccess from primary.services.utils.authenticated_user import AuthenticatedUser +from primary.utils.query_string_utils import decode_uint_list_str from . import schemas from . import converters @@ -35,8 +36,12 @@ async def get_realization_data( well_name: Annotated[str, Query(description="Well name")], response_name: Annotated[str, Query(description="Response name")], timestamps_utc_ms: Annotated[list[int] | None, Query(description="Timestamps utc ms")] = None, - realizations: Annotated[list[int] | None, Query(description="Realizations")] = None, + realizations_encoded_as_uint_list_str: Annotated[str | None, Query(description="Optional list of realizations encoded as string to include. If not specified, all realizations will be included.")] = None, ) -> list[schemas.RftRealizationData]: + realizations: list[int]|None = None + if realizations_encoded_as_uint_list_str: + realizations = decode_uint_list_str(realizations_encoded_as_uint_list_str) + access = await RftAccess.from_case_uuid_async(authenticated_user.get_sumo_access_token(), case_uuid, ensemble_name) data = await access.get_rft_well_realization_data( well_name=well_name, diff --git a/backend_py/primary/primary/routers/surface/router.py b/backend_py/primary/primary/routers/surface/router.py index 11b12e1f0..fec27c074 100644 --- a/backend_py/primary/primary/routers/surface/router.py +++ b/backend_py/primary/primary/routers/surface/router.py @@ -288,7 +288,7 @@ async def get_misfit_surface_data( obs_surf_addr_str: Annotated[str, Query(description="Address of observed surface, only supported address type is *OBS*")], sim_surf_addr_str: Annotated[str, Query(description="Address of simulated surface, supported type is *PARTIAL*")], statistic_functions: Annotated[list[schemas.SurfaceStatisticFunction], Query(description="Statistics to calculate")], - realizations: Annotated[list[int], Query(description="Realization numbers")], + realizations_encoded_as_uint_list_str: Annotated[str | None, Query(description="Optional list of realizations encoded as string to include. If not specified, all realizations will be included.")] = None, data_format: Annotated[Literal["float", "png"], Query(description="Format of binary data in the response")] = "float", resample_to: Annotated[schemas.SurfaceDef | None, Depends(dependencies.get_resample_to_param_from_keyval_str)] = None, # fmt:on diff --git a/backend_py/primary/primary/routers/timeseries/router.py b/backend_py/primary/primary/routers/timeseries/router.py index 9f0a88708..fc1ebe9b1 100644 --- a/backend_py/primary/primary/routers/timeseries/router.py +++ b/backend_py/primary/primary/routers/timeseries/router.py @@ -12,6 +12,7 @@ from primary.services.sumo_access.parameter_access import ParameterAccess from primary.services.sumo_access.summary_access import Frequency, SummaryAccess from primary.services.utils.authenticated_user import AuthenticatedUser +from primary.utils.query_string_utils import decode_uint_list_str from . import converters, schemas @@ -57,13 +58,18 @@ async def get_realizations_vector_data( ensemble_name: Annotated[str, Query(description="Ensemble name")], vector_name: Annotated[str, Query(description="Name of the vector")], resampling_frequency: Annotated[schemas.Frequency | None, Query(description="Resampling frequency. If not specified, raw data without resampling wil be returned.")] = None, - realizations: Annotated[list[int] | None, Query(description="Optional list of realizations to include. If not specified, all realizations will be returned.")] = None, + realizations_encoded_as_uint_list_str: Annotated[str | None, Query(description="Optional list of realizations encoded as string to include. If not specified, all realizations will be included.")] = None, # relative_to_timestamp: Annotated[datetime.datetime | None, Query(description="Calculate relative to timestamp")] = None, # fmt:on ) -> list[schemas.VectorRealizationData]: """Get vector data per realization""" - + perf_metrics = ResponsePerfMetrics(response) + + realizations: list[int]|None = None + if realizations_encoded_as_uint_list_str: + realizations = decode_uint_list_str(realizations_encoded_as_uint_list_str) + access = SummaryAccess.from_case_uuid(authenticated_user.get_sumo_access_token(), case_uuid, ensemble_name) sumo_freq = Frequency.from_string_value(resampling_frequency.value if resampling_frequency else "dummy") @@ -97,7 +103,6 @@ async def get_timestamps_list( case_uuid: Annotated[str, Query(description="Sumo case uuid")], ensemble_name: Annotated[str, Query(description="Ensemble name")], resampling_frequency: Annotated[schemas.Frequency | None, Query(description="Resampling frequency")] = None, - # realizations: Annotated[list[int] | None, Query(description="Optional list of realizations to include")] = None, ) -> list[int]: """Get the intersection of available timestamps. Note that when resampling_frequency is None, the pure intersection of the @@ -149,7 +154,7 @@ async def get_statistical_vector_data( vector_name: Annotated[str, Query(description="Name of the vector")], resampling_frequency: Annotated[schemas.Frequency, Query(description="Resampling frequency")], statistic_functions: Annotated[list[schemas.StatisticFunction] | None, Query(description="Optional list of statistics to calculate. If not specified, all statistics will be calculated.")] = None, - realizations: Annotated[list[int] | None, Query(description="Optional list of realizations to include. If not specified, all realizations will be included.")] = None, + realizations_encoded_as_uint_list_str: Annotated[str | None, Query(description="Optional list of realizations encoded as string to include. If not specified, all realizations will be included.")] = None, # relative_to_timestamp: Annotated[datetime.datetime | None, Query(description="Calculate relative to timestamp")] = None, # fmt:on ) -> schemas.VectorStatisticData: @@ -157,6 +162,10 @@ async def get_statistical_vector_data( perf_metrics = ResponsePerfMetrics(response) + realizations: list[int]|None = None + if realizations_encoded_as_uint_list_str: + realizations = decode_uint_list_str(realizations_encoded_as_uint_list_str) + access = SummaryAccess.from_case_uuid(authenticated_user.get_sumo_access_token(), case_uuid, ensemble_name) service_freq = Frequency.from_string_value(resampling_frequency.value) @@ -242,7 +251,6 @@ async def get_realization_vector_at_timestamp( ensemble_name: Annotated[str, Query(description="Ensemble name")], vector_name: Annotated[str, Query(description="Name of the vector")], timestamp_utc_ms: Annotated[int, Query(description= "Timestamp in ms UTC to query vectors at")], - # realizations: Annotated[list[int] | None, Query(description="Optional list of realizations to include. If not specified, all realizations will be returned.")] = None, # fmt:on ) -> EnsembleScalarResponse: summary_access = SummaryAccess.from_case_uuid(authenticated_user.get_sumo_access_token(), case_uuid, ensemble_name) diff --git a/frontend/src/api/services/InplaceVolumetricsService.ts b/frontend/src/api/services/InplaceVolumetricsService.ts index bf32c0755..01c3f85c5 100644 --- a/frontend/src/api/services/InplaceVolumetricsService.ts +++ b/frontend/src/api/services/InplaceVolumetricsService.ts @@ -51,7 +51,7 @@ export class InplaceVolumetricsService { * @param accumulateFluidZones Whether to accumulate fluid zones * @param requestBody * @param groupByIdentifiers The identifiers to group table data by - * @param realizations Optional list of realizations to include. If not specified, all realizations will be returned. + * @param realizationsEncodedAsUintListStr Optional list of realizations encoded as string to include. If not specified, all realizations will be included. * @returns InplaceVolumetricTableDataPerFluidSelection Successful Response * @throws ApiError */ @@ -64,7 +64,7 @@ export class InplaceVolumetricsService { accumulateFluidZones: boolean, requestBody: Body_post_get_aggregated_per_realization_table_data, groupByIdentifiers?: (Array | null), - realizations?: (Array | null), + realizationsEncodedAsUintListStr?: (string | null), ): CancelablePromise { return this.httpRequest.request({ method: 'POST', @@ -77,7 +77,7 @@ export class InplaceVolumetricsService { 'fluid_zones': fluidZones, 'accumulate_fluid_zones': accumulateFluidZones, 'group_by_identifiers': groupByIdentifiers, - 'realizations': realizations, + 'realizations_encoded_as_uint_list_str': realizationsEncodedAsUintListStr, }, body: requestBody, mediaType: 'application/json', @@ -100,7 +100,7 @@ export class InplaceVolumetricsService { * @param accumulateFluidZones Whether to accumulate fluid zones * @param requestBody * @param groupByIdentifiers The identifiers to group table data by - * @param realizations Optional list of realizations to include. If not specified, all realizations will be returned. + * @param realizationsEncodedAsUintListStr Optional list of realizations encoded as string to include. If not specified, all realizations will be included. * @returns InplaceStatisticalVolumetricTableDataPerFluidSelection Successful Response * @throws ApiError */ @@ -113,7 +113,7 @@ export class InplaceVolumetricsService { accumulateFluidZones: boolean, requestBody: Body_post_get_aggregated_statistical_table_data, groupByIdentifiers?: (Array | null), - realizations?: (Array | null), + realizationsEncodedAsUintListStr?: (string | null), ): CancelablePromise { return this.httpRequest.request({ method: 'POST', @@ -126,7 +126,7 @@ export class InplaceVolumetricsService { 'fluid_zones': fluidZones, 'accumulate_fluid_zones': accumulateFluidZones, 'group_by_identifiers': groupByIdentifiers, - 'realizations': realizations, + 'realizations_encoded_as_uint_list_str': realizationsEncodedAsUintListStr, }, body: requestBody, mediaType: 'application/json', diff --git a/frontend/src/api/services/RftService.ts b/frontend/src/api/services/RftService.ts index 252a5933a..b171a4c00 100644 --- a/frontend/src/api/services/RftService.ts +++ b/frontend/src/api/services/RftService.ts @@ -38,7 +38,7 @@ export class RftService { * @param wellName Well name * @param responseName Response name * @param timestampsUtcMs Timestamps utc ms - * @param realizations Realizations + * @param realizationsEncodedAsUintListStr Optional list of realizations encoded as string to include. If not specified, all realizations will be included. * @returns RftRealizationData Successful Response * @throws ApiError */ @@ -48,7 +48,7 @@ export class RftService { wellName: string, responseName: string, timestampsUtcMs?: (Array | null), - realizations?: (Array | null), + realizationsEncodedAsUintListStr?: (string | null), ): CancelablePromise> { return this.httpRequest.request({ method: 'GET', @@ -59,7 +59,7 @@ export class RftService { 'well_name': wellName, 'response_name': responseName, 'timestamps_utc_ms': timestampsUtcMs, - 'realizations': realizations, + 'realizations_encoded_as_uint_list_str': realizationsEncodedAsUintListStr, }, errors: { 422: `Validation Error`, diff --git a/frontend/src/api/services/SurfaceService.ts b/frontend/src/api/services/SurfaceService.ts index b4e01dbb7..d4d7e59a2 100644 --- a/frontend/src/api/services/SurfaceService.ts +++ b/frontend/src/api/services/SurfaceService.ts @@ -220,7 +220,7 @@ export class SurfaceService { * @param obsSurfAddrStr Address of observed surface, only supported address type is *OBS* * @param simSurfAddrStr Address of simulated surface, supported type is *PARTIAL* * @param statisticFunctions Statistics to calculate - * @param realizations Realization numbers + * @param realizationsEncodedAsUintListStr Optional list of realizations encoded as string to include. If not specified, all realizations will be included. * @param dataFormat Format of binary data in the response * @param resampleToDefStr Definition of the surface onto which the data should be resampled. *SurfaceDef* object properties encoded as a `KeyValStr` string. * @returns SurfaceDataFloat Successful Response @@ -230,7 +230,7 @@ export class SurfaceService { obsSurfAddrStr: string, simSurfAddrStr: string, statisticFunctions: Array, - realizations: Array, + realizationsEncodedAsUintListStr?: (string | null), dataFormat: 'float' | 'png' = 'float', resampleToDefStr?: (string | null), ): CancelablePromise> { @@ -241,7 +241,7 @@ export class SurfaceService { 'obs_surf_addr_str': obsSurfAddrStr, 'sim_surf_addr_str': simSurfAddrStr, 'statistic_functions': statisticFunctions, - 'realizations': realizations, + 'realizations_encoded_as_uint_list_str': realizationsEncodedAsUintListStr, 'data_format': dataFormat, 'resample_to_def_str': resampleToDefStr, }, diff --git a/frontend/src/api/services/TimeseriesService.ts b/frontend/src/api/services/TimeseriesService.ts index b872c2ed4..a77b0270b 100644 --- a/frontend/src/api/services/TimeseriesService.ts +++ b/frontend/src/api/services/TimeseriesService.ts @@ -45,7 +45,7 @@ export class TimeseriesService { * @param ensembleName Ensemble name * @param vectorName Name of the vector * @param resamplingFrequency Resampling frequency. If not specified, raw data without resampling wil be returned. - * @param realizations Optional list of realizations to include. If not specified, all realizations will be returned. + * @param realizationsEncodedAsUintListStr Optional list of realizations encoded as string to include. If not specified, all realizations will be included. * @returns VectorRealizationData Successful Response * @throws ApiError */ @@ -54,7 +54,7 @@ export class TimeseriesService { ensembleName: string, vectorName: string, resamplingFrequency?: (Frequency | null), - realizations?: (Array | null), + realizationsEncodedAsUintListStr?: (string | null), ): CancelablePromise> { return this.httpRequest.request({ method: 'GET', @@ -64,7 +64,7 @@ export class TimeseriesService { 'ensemble_name': ensembleName, 'vector_name': vectorName, 'resampling_frequency': resamplingFrequency, - 'realizations': realizations, + 'realizations_encoded_as_uint_list_str': realizationsEncodedAsUintListStr, }, errors: { 422: `Validation Error`, @@ -140,7 +140,7 @@ export class TimeseriesService { * @param vectorName Name of the vector * @param resamplingFrequency Resampling frequency * @param statisticFunctions Optional list of statistics to calculate. If not specified, all statistics will be calculated. - * @param realizations Optional list of realizations to include. If not specified, all realizations will be included. + * @param realizationsEncodedAsUintListStr Optional list of realizations encoded as string to include. If not specified, all realizations will be included. * @returns VectorStatisticData Successful Response * @throws ApiError */ @@ -150,7 +150,7 @@ export class TimeseriesService { vectorName: string, resamplingFrequency: Frequency, statisticFunctions?: (Array | null), - realizations?: (Array | null), + realizationsEncodedAsUintListStr?: (string | null), ): CancelablePromise { return this.httpRequest.request({ method: 'GET', @@ -161,7 +161,7 @@ export class TimeseriesService { 'vector_name': vectorName, 'resampling_frequency': resamplingFrequency, 'statistic_functions': statisticFunctions, - 'realizations': realizations, + 'realizations_encoded_as_uint_list_str': realizationsEncodedAsUintListStr, }, errors: { 422: `Validation Error`, diff --git a/frontend/src/modules/SimulationTimeSeries/view/atoms/queryAtoms.ts b/frontend/src/modules/SimulationTimeSeries/view/atoms/queryAtoms.ts index bb57272dd..e4a94625c 100644 --- a/frontend/src/modules/SimulationTimeSeries/view/atoms/queryAtoms.ts +++ b/frontend/src/modules/SimulationTimeSeries/view/atoms/queryAtoms.ts @@ -2,6 +2,7 @@ import { Frequency_api, Observations_api } from "@api"; import { apiService } from "@framework/ApiService"; import { ValidEnsembleRealizationsFunctionAtom } from "@framework/GlobalAtoms"; import { atomWithQueries } from "@framework/utils/atomUtils"; +import { encodeAsUintListStr } from "@lib/utils/queryStringUtils"; import { EnsembleVectorObservationDataMap, VisualizationMode } from "@modules/SimulationTimeSeries/typesAndEnums"; import { QueryObserverResult } from "@tanstack/react-query"; @@ -27,6 +28,8 @@ export const vectorDataQueriesAtom = atomWithQueries((get) => { const queries = vectorSpecifications.map((item) => { const realizations = [...validEnsembleRealizationsFunction(item.ensembleIdent)]; + const realizationsEncodedAsUintListStr = realizations ? encodeAsUintListStr(realizations) : null; + return () => ({ queryKey: [ "getRealizationsVectorData", @@ -34,7 +37,7 @@ export const vectorDataQueriesAtom = atomWithQueries((get) => { item.ensembleIdent.getEnsembleName(), item.vectorName, resampleFrequency, - realizations, + realizationsEncodedAsUintListStr, ], queryFn: () => apiService.timeseries.getRealizationsVectorData( @@ -42,7 +45,7 @@ export const vectorDataQueriesAtom = atomWithQueries((get) => { item.ensembleIdent.getEnsembleName() ?? "", item.vectorName ?? "", resampleFrequency, - realizations + realizationsEncodedAsUintListStr ), staleTime: STALE_TIME, gcTime: CACHE_TIME, @@ -73,6 +76,8 @@ export const vectorStatisticsQueriesAtom = atomWithQueries((get) => { const queries = vectorSpecifications.map((item) => { const realizations = [...validEnsembleRealizationsFunction(item.ensembleIdent)]; + const realizationsEncodedAsUintListStr = realizations ? encodeAsUintListStr(realizations) : null; + return () => ({ queryKey: [ "getStatisticalVectorData", @@ -80,7 +85,7 @@ export const vectorStatisticsQueriesAtom = atomWithQueries((get) => { item.ensembleIdent.getEnsembleName(), item.vectorName, resampleFrequency, - realizations, + realizationsEncodedAsUintListStr, ], queryFn: () => apiService.timeseries.getStatisticalVectorData( @@ -89,7 +94,7 @@ export const vectorStatisticsQueriesAtom = atomWithQueries((get) => { item.vectorName ?? "", resampleFrequency ?? Frequency_api.MONTHLY, undefined, - realizations + realizationsEncodedAsUintListStr ), staleTime: STALE_TIME, gcTime: CACHE_TIME, diff --git a/frontend/src/modules/SimulationTimeSeriesSensitivity/queryHooks.tsx b/frontend/src/modules/SimulationTimeSeriesSensitivity/queryHooks.tsx index 8f53b0afe..727c754bb 100644 --- a/frontend/src/modules/SimulationTimeSeriesSensitivity/queryHooks.tsx +++ b/frontend/src/modules/SimulationTimeSeriesSensitivity/queryHooks.tsx @@ -1,6 +1,7 @@ import { Frequency_api, VectorHistoricalData_api, VectorStatisticSensitivityData_api } from "@api"; import { VectorRealizationData_api } from "@api"; import { apiService } from "@framework/ApiService"; +import { encodeAsUintListStr } from "@lib/utils/queryStringUtils"; import { UseQueryResult, useQuery } from "@tanstack/react-query"; const STALE_TIME = 60 * 1000; @@ -14,6 +15,7 @@ export function useVectorDataQuery( realizationsToInclude: number[] | null ): UseQueryResult> { const allOrNonEmptyRealArr = realizationsToInclude === null || realizationsToInclude.length > 0 ? true : false; + const realizationsEncodedAsUintListStr = realizationsToInclude ? encodeAsUintListStr(realizationsToInclude) : null; return useQuery({ queryKey: [ "getRealizationsVectorData", @@ -21,7 +23,7 @@ export function useVectorDataQuery( ensembleName, vectorName, resampleFrequency, - realizationsToInclude, + realizationsEncodedAsUintListStr, ], queryFn: () => apiService.timeseries.getRealizationsVectorData( @@ -29,7 +31,7 @@ export function useVectorDataQuery( ensembleName ?? "", vectorName ?? "", resampleFrequency ?? undefined, - realizationsToInclude ?? undefined + realizationsEncodedAsUintListStr ), staleTime: STALE_TIME, gcTime: CACHE_TIME, diff --git a/frontend/src/modules/_shared/InplaceVolumetrics/queryHooks.ts b/frontend/src/modules/_shared/InplaceVolumetrics/queryHooks.ts index 31d9e1340..c2aa60e41 100644 --- a/frontend/src/modules/_shared/InplaceVolumetrics/queryHooks.ts +++ b/frontend/src/modules/_shared/InplaceVolumetrics/queryHooks.ts @@ -8,6 +8,7 @@ import { } from "@api"; import { apiService } from "@framework/ApiService"; import { EnsembleIdent } from "@framework/EnsembleIdent"; +import { encodeAsUintListStr } from "@lib/utils/queryStringUtils"; import { InplaceVolumetricsStatisticalTableData, InplaceVolumetricsTableData, @@ -60,6 +61,7 @@ export function useGetAggregatedStatisticalTableDataQueries( const queries = uniqueSources.map((source) => { const validRealizations = source.realizations.length === 0 ? null : [...source.realizations]; + const validRealizationsEncodedAsUintListStr = validRealizations ? encodeAsUintListStr(validRealizations) : null; return () => ({ queryKey: [ "postGetAggregatedStatisticalTableData", @@ -84,7 +86,7 @@ export function useGetAggregatedStatisticalTableDataQueries( identifiers_with_values: identifiersWithValues, }, validGroupByIdentifiers, - validRealizations + validRealizationsEncodedAsUintListStr ), staleTime: STALE_TIME, cacheTime: CACHE_TIME, @@ -92,8 +94,8 @@ export function useGetAggregatedStatisticalTableDataQueries( allowEnable && source.ensembleIdent && source.tableName && - validRealizations && - validRealizations.length && + validRealizationsEncodedAsUintListStr && + validRealizations?.length && fluidZones.length && resultNames.length && eachIdentifierHasValues @@ -156,6 +158,7 @@ export function useGetAggregatedPerRealizationTableDataQueries( const queries = uniqueSources.map((source) => { const validRealizations = source.realizations.length === 0 ? null : [...source.realizations]; + const validRealizationsEncodedAsUintListStr = validRealizations ? encodeAsUintListStr(validRealizations) : null; return () => ({ queryKey: [ "postGetAggregatedPerRealizationTableData", @@ -181,7 +184,7 @@ export function useGetAggregatedPerRealizationTableDataQueries( identifiers_with_values: identifiersWithValues, }, validGroupByIdentifiers, - validRealizations + validRealizationsEncodedAsUintListStr ), staleTime: STALE_TIME, cacheTime: CACHE_TIME, @@ -189,8 +192,8 @@ export function useGetAggregatedPerRealizationTableDataQueries( allowEnable && source.ensembleIdent && source.tableName && - validRealizations && - validRealizations.length && + validRealizationsEncodedAsUintListStr && + validRealizations?.length && fluidZones.length && resultNames.length && eachIdentifierHasValues