diff --git a/frontend/packages/data-portal/app/graphql/fragments/getDatasetsFilterValuesV2.server.ts b/frontend/packages/data-portal/app/graphql/fragments/getDatasetsFilterValuesV2.server.ts index 5d5bb8586..d9eaee4b2 100644 --- a/frontend/packages/data-portal/app/graphql/fragments/getDatasetsFilterValuesV2.server.ts +++ b/frontend/packages/data-portal/app/graphql/fragments/getDatasetsFilterValuesV2.server.ts @@ -1,13 +1,15 @@ import { gql } from 'app/__generated_v2__' /** - * Shares filter options queries between datasets and deposition pages (filters are near identical). + * Shares aggregate queries between datasets and deposition pages (the 2 pages are very similar). * - * Parent query must define $depositionFilter. + * Parent query must define $depositionIdFilter. If $depositionIdFilter is undefined, the queries + * will count everything. It makes the fragment significantly more readable to allow sending an + * empty argument object. */ -export const GET_DATASETS_FILTER_VALUES_FRAGMENT = gql(` +export const GET_DATASETS_AGGREGATES_FRAGMENT = gql(` fragment DatasetsAggregates on Query { - distinctOrganismNames: datasetsAggregate(where: { depositionId: $depositionFilter }) { + distinctOrganismNames: datasetsAggregate(where: { depositionId: $depositionIdFilter }) { aggregate { count groupBy { @@ -16,7 +18,7 @@ export const GET_DATASETS_FILTER_VALUES_FRAGMENT = gql(` } } - distinctCameraManufacturers: tiltseriesAggregate(where: { depositionId: $depositionFilter }) { + distinctCameraManufacturers: tiltseriesAggregate(where: { depositionId: $depositionIdFilter }) { aggregate { count groupBy { @@ -25,7 +27,7 @@ export const GET_DATASETS_FILTER_VALUES_FRAGMENT = gql(` } } - distinctReconstructionMethods: tomogramsAggregate(where: { depositionId: $depositionFilter }) { + distinctReconstructionMethods: tomogramsAggregate(where: { depositionId: $depositionIdFilter }) { aggregate { count groupBy { @@ -34,7 +36,7 @@ export const GET_DATASETS_FILTER_VALUES_FRAGMENT = gql(` } } - distinctReconstructionSoftwares: tomogramsAggregate(where: { depositionId: $depositionFilter }) { + distinctReconstructionSoftwares: tomogramsAggregate(where: { depositionId: $depositionIdFilter }) { aggregate { count groupBy { @@ -43,7 +45,7 @@ export const GET_DATASETS_FILTER_VALUES_FRAGMENT = gql(` } } - distinctObjectNames: annotationsAggregate(where: { depositionId: $depositionFilter }) { + distinctObjectNames: annotationsAggregate(where: { depositionId: $depositionIdFilter }) { aggregate { count groupBy { @@ -52,7 +54,7 @@ export const GET_DATASETS_FILTER_VALUES_FRAGMENT = gql(` } } - distinctShapeTypes: annotationShapesAggregate(where: { annotation: { depositionId: $depositionFilter } }) { + distinctShapeTypes: annotationShapesAggregate(where: { annotation: { depositionId: $depositionIdFilter } }) { aggregate { count groupBy { diff --git a/frontend/packages/data-portal/app/graphql/getDatasetsV2.server.ts b/frontend/packages/data-portal/app/graphql/getDatasetsV2.server.ts index dbfffad43..78938cb28 100644 --- a/frontend/packages/data-portal/app/graphql/getDatasetsV2.server.ts +++ b/frontend/packages/data-portal/app/graphql/getDatasetsV2.server.ts @@ -27,7 +27,7 @@ const GET_DATASETS_QUERY = gql(` $offset: Int, $orderBy: [DatasetOrderByClause!]!, $filter: DatasetWhereClause!, - $depositionFilter: IntComparators # Unused, but must be defined because DatasetsFilterValues references it. + $depositionIdFilter: IntComparators # Unused, but must be defined because DatasetsFilterValues references it. ) { datasets( where: $filter @@ -80,7 +80,7 @@ const GET_DATASETS_QUERY = gql(` } } - ...DatasetsFilterValues + ...DatasetsAggregates @include(if: $filterByDeposition) } `)