Skip to content

Commit

Permalink
perf: Disable loading of dimension values for preview query
Browse files Browse the repository at this point in the history
  • Loading branch information
bprusinowski committed Sep 26, 2023
1 parent 28b8e9a commit 6892cf3
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 11 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ You can also check the [release page](https://github.com/visualize-admin/visuali

- Fixes
- Cube checker now correctly checks if dimensions are present
- Performance
- Dataset preview should now load quicker as we no longer fetch dimension values along with it

# [3.22.6] - 2023-09-19

Expand Down
25 changes: 22 additions & 3 deletions app/graphql/queries/data-cubes.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ fragment dimensionMetadata on Dimension {
dataType
scaleType
order
values(sourceType: $sourceType, sourceUrl: $sourceUrl, filters: $filters)
values(
sourceType: $sourceType
sourceUrl: $sourceUrl
filters: $filters
disableLoad: $isPreview
)
unit
related {
iri
Expand Down Expand Up @@ -120,22 +125,32 @@ query DataCubePreview(
$locale: String!
$latest: Boolean
$filters: Filters
$isPreview: Boolean = true
) {
dataCubeByIri(
iri: $iri
sourceType: $sourceType
sourceUrl: $sourceUrl
locale: $locale
latest: $latest
isPreview: $isPreview
) {
iri
title
description
publicationStatus
dimensions(sourceType: $sourceType, sourceUrl: $sourceUrl) {
dimensions(
sourceType: $sourceType
sourceUrl: $sourceUrl
disableValuesLoad: $isPreview
) {
...dimensionMetadata
}
measures(sourceType: $sourceType, sourceUrl: $sourceUrl) {
measures(
sourceType: $sourceType
sourceUrl: $sourceUrl
disableValuesLoad: $isPreview
) {
...dimensionMetadata
}
observations(sourceType: $sourceType, sourceUrl: $sourceUrl, limit: 10) {
Expand Down Expand Up @@ -193,25 +208,29 @@ query Components(
$latest: Boolean
$filters: Filters
$componentIris: [String!]
$isPreview: Boolean = false
) {
dataCubeByIri(
iri: $iri
sourceType: $sourceType
sourceUrl: $sourceUrl
locale: $locale
latest: $latest
isPreview: $isPreview
) {
dimensions(
sourceType: $sourceType
sourceUrl: $sourceUrl
componentIris: $componentIris
disableValuesLoad: $isPreview
) {
...dimensionMetadata
}
measures(
sourceType: $sourceType
sourceUrl: $sourceUrl
componentIris: $componentIris
disableValuesLoad: $isPreview
) {
...dimensionMetadata
}
Expand Down
42 changes: 37 additions & 5 deletions app/graphql/query-hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export type DataCubeDimensionsArgs = {
sourceType: Scalars['String'];
sourceUrl: Scalars['String'];
componentIris?: Maybe<Array<Scalars['String']>>;
disableValuesLoad?: Maybe<Scalars['Boolean']>;
};


Expand All @@ -78,6 +79,7 @@ export type DataCubeMeasuresArgs = {
sourceType: Scalars['String'];
sourceUrl: Scalars['String'];
componentIris?: Maybe<Array<Scalars['String']>>;
disableValuesLoad?: Maybe<Scalars['Boolean']>;
};

export type DataCubeOrganization = {
Expand Down Expand Up @@ -142,6 +144,7 @@ export type DimensionValuesArgs = {
sourceType: Scalars['String'];
sourceUrl: Scalars['String'];
filters?: Maybe<Scalars['Filters']>;
disableLoad?: Maybe<Scalars['Boolean']>;
};


Expand Down Expand Up @@ -183,6 +186,7 @@ export type GeoCoordinatesDimensionValuesArgs = {
sourceType: Scalars['String'];
sourceUrl: Scalars['String'];
filters?: Maybe<Scalars['Filters']>;
disableLoad?: Maybe<Scalars['Boolean']>;
};


Expand Down Expand Up @@ -214,6 +218,7 @@ export type GeoShapesDimensionValuesArgs = {
sourceType: Scalars['String'];
sourceUrl: Scalars['String'];
filters?: Maybe<Scalars['Filters']>;
disableLoad?: Maybe<Scalars['Boolean']>;
};


Expand Down Expand Up @@ -258,6 +263,7 @@ export type NominalDimensionValuesArgs = {
sourceType: Scalars['String'];
sourceUrl: Scalars['String'];
filters?: Maybe<Scalars['Filters']>;
disableLoad?: Maybe<Scalars['Boolean']>;
};


Expand Down Expand Up @@ -291,6 +297,7 @@ export type NumericalMeasureValuesArgs = {
sourceType: Scalars['String'];
sourceUrl: Scalars['String'];
filters?: Maybe<Scalars['Filters']>;
disableLoad?: Maybe<Scalars['Boolean']>;
};


Expand Down Expand Up @@ -340,6 +347,7 @@ export type OrdinalDimensionValuesArgs = {
sourceType: Scalars['String'];
sourceUrl: Scalars['String'];
filters?: Maybe<Scalars['Filters']>;
disableLoad?: Maybe<Scalars['Boolean']>;
};


Expand Down Expand Up @@ -369,6 +377,7 @@ export type OrdinalMeasureValuesArgs = {
sourceType: Scalars['String'];
sourceUrl: Scalars['String'];
filters?: Maybe<Scalars['Filters']>;
disableLoad?: Maybe<Scalars['Boolean']>;
};


Expand Down Expand Up @@ -397,6 +406,7 @@ export type QueryDataCubeByIriArgs = {
latest?: Maybe<Scalars['Boolean']>;
filters?: Maybe<Scalars['Filters']>;
componentIris?: Maybe<Array<Scalars['String']>>;
isPreview?: Maybe<Scalars['Boolean']>;
};


Expand Down Expand Up @@ -485,6 +495,7 @@ export type StandardErrorDimensionValuesArgs = {
sourceType: Scalars['String'];
sourceUrl: Scalars['String'];
filters?: Maybe<Scalars['Filters']>;
disableLoad?: Maybe<Scalars['Boolean']>;
};


Expand Down Expand Up @@ -516,6 +527,7 @@ export type TemporalDimensionValuesArgs = {
sourceType: Scalars['String'];
sourceUrl: Scalars['String'];
filters?: Maybe<Scalars['Filters']>;
disableLoad?: Maybe<Scalars['Boolean']>;
};


Expand Down Expand Up @@ -545,6 +557,7 @@ export type TemporalOrdinalDimensionValuesArgs = {
sourceType: Scalars['String'];
sourceUrl: Scalars['String'];
filters?: Maybe<Scalars['Filters']>;
disableLoad?: Maybe<Scalars['Boolean']>;
};


Expand Down Expand Up @@ -834,6 +847,7 @@ export type DataCubePreviewQueryVariables = Exact<{
locale: Scalars['String'];
latest?: Maybe<Scalars['Boolean']>;
filters?: Maybe<Scalars['Filters']>;
isPreview?: Maybe<Scalars['Boolean']>;
}>;


Expand Down Expand Up @@ -891,6 +905,7 @@ export type ComponentsQueryVariables = Exact<{
latest?: Maybe<Scalars['Boolean']>;
filters?: Maybe<Scalars['Filters']>;
componentIris?: Maybe<Array<Scalars['String']> | Scalars['String']>;
isPreview?: Maybe<Scalars['Boolean']>;
}>;


Expand Down Expand Up @@ -1153,7 +1168,12 @@ export const DimensionMetadataFragmentDoc = gql`
dataType
scaleType
order
values(sourceType: $sourceType, sourceUrl: $sourceUrl, filters: $filters)
values(
sourceType: $sourceType
sourceUrl: $sourceUrl
filters: $filters
disableLoad: $isPreview
)
unit
related {
iri
Expand Down Expand Up @@ -1271,22 +1291,31 @@ export function useDataCubesQuery(options: Omit<Urql.UseQueryArgs<DataCubesQuery
return Urql.useQuery<DataCubesQuery>({ query: DataCubesDocument, ...options });
};
export const DataCubePreviewDocument = gql`
query DataCubePreview($iri: String!, $sourceType: String!, $sourceUrl: String!, $locale: String!, $latest: Boolean, $filters: Filters) {
query DataCubePreview($iri: String!, $sourceType: String!, $sourceUrl: String!, $locale: String!, $latest: Boolean, $filters: Filters, $isPreview: Boolean = true) {
dataCubeByIri(
iri: $iri
sourceType: $sourceType
sourceUrl: $sourceUrl
locale: $locale
latest: $latest
isPreview: $isPreview
) {
iri
title
description
publicationStatus
dimensions(sourceType: $sourceType, sourceUrl: $sourceUrl) {
dimensions(
sourceType: $sourceType
sourceUrl: $sourceUrl
disableValuesLoad: $isPreview
) {
...dimensionMetadata
}
measures(sourceType: $sourceType, sourceUrl: $sourceUrl) {
measures(
sourceType: $sourceType
sourceUrl: $sourceUrl
disableValuesLoad: $isPreview
) {
...dimensionMetadata
}
observations(sourceType: $sourceType, sourceUrl: $sourceUrl, limit: 10) {
Expand Down Expand Up @@ -1340,25 +1369,28 @@ export function useDataCubeMetadataQuery(options: Omit<Urql.UseQueryArgs<DataCub
return Urql.useQuery<DataCubeMetadataQuery>({ query: DataCubeMetadataDocument, ...options });
};
export const ComponentsDocument = gql`
query Components($iri: String!, $sourceType: String!, $sourceUrl: String!, $locale: String!, $latest: Boolean, $filters: Filters, $componentIris: [String!]) {
query Components($iri: String!, $sourceType: String!, $sourceUrl: String!, $locale: String!, $latest: Boolean, $filters: Filters, $componentIris: [String!], $isPreview: Boolean = false) {
dataCubeByIri(
iri: $iri
sourceType: $sourceType
sourceUrl: $sourceUrl
locale: $locale
latest: $latest
isPreview: $isPreview
) {
dimensions(
sourceType: $sourceType
sourceUrl: $sourceUrl
componentIris: $componentIris
disableValuesLoad: $isPreview
) {
...dimensionMetadata
}
measures(
sourceType: $sourceType
sourceUrl: $sourceUrl
componentIris: $componentIris
disableValuesLoad: $isPreview
) {
...dimensionMetadata
}
Expand Down
Loading

0 comments on commit 6892cf3

Please sign in to comment.