Skip to content

Commit

Permalink
perf: Only load key dimension and measure values
Browse files Browse the repository at this point in the history
  • Loading branch information
bprusinowski committed Nov 18, 2024
1 parent c3587b3 commit 19c2267
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
1 change: 1 addition & 0 deletions app/configurator/configurator-state/index.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ Object.assign(mockClient, {
query: jest.fn().mockImplementation(() => ({
toPromise: jest.fn().mockResolvedValue({
data: {
dataCubePreview: getCachedComponentsMock.geoAndNumerical,
possibleFilters,
},
}),
Expand Down
28 changes: 27 additions & 1 deletion app/configurator/configurator-state/init.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ import {
import { SELECTING_DATASET_STATE } from "@/configurator/configurator-state/initial";
import { executeDataCubesComponentsQuery } from "@/graphql/hooks";
import {
DataCubePreviewDocument,
DataCubePreviewQuery,
DataCubePreviewQueryVariables,
PossibleFiltersDocument,
PossibleFiltersQuery,
PossibleFiltersQueryVariables,
Expand Down Expand Up @@ -43,11 +46,34 @@ export const initChartStateFromCube = async (
dataSource,
});

const { data: dataCubePreview } = await client
.query<DataCubePreviewQuery, DataCubePreviewQueryVariables>(
DataCubePreviewDocument,
{
sourceType: dataSource.type,
sourceUrl: dataSource.url,
locale,
cubeFilter: { iri: cubeIri },
}
)
.toPromise();

const { data: components } = await executeDataCubesComponentsQuery(client, {
sourceType: dataSource.type,
sourceUrl: dataSource.url,
locale,
cubeFilters: [{ iri: cubeIri, loadValues: true }],
cubeFilters: [
{
iri: cubeIri,
componentIris: [
...(dataCubePreview?.dataCubePreview.dimensions.filter(
(d) => d.isKeyDimension
) ?? []),
...(dataCubePreview?.dataCubePreview.measures ?? []),
].map((d) => d.iri),
loadValues: true,
},
],
});

if (!components?.dataCubesComponents) {
Expand Down

0 comments on commit 19c2267

Please sign in to comment.