Skip to content

Commit 8f4d7b2

Browse files
authored
Merge pull request #3364 from OpenNeuroOrg/update/nihbi-dataset-count
adding query to check for nih datasets and excluding participant count for 0
2 parents 22f7118 + 303bf1c commit 8f4d7b2

File tree

2 files changed

+32
-7
lines changed

2 files changed

+32
-7
lines changed

packages/openneuro-app/src/scripts/pages/front-page/aggregate-queries/aggregate-counts-container.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,16 @@ const AggregateCountsContainer: React.FC<AggregateCountsContainerProps> = ({
2929
else {
3030
return (
3131
<>
32-
<AggregateCount
33-
type="participants"
34-
count={participantData.participantCount}
35-
/>
32+
{participantData.participantCount > 0 && (
33+
<AggregateCount
34+
type="participants"
35+
count={participantData.participantCount}
36+
/>
37+
)}
3638
<AggregateCount
3739
type="publicDataset"
38-
count={publicDatasetsData.datasets?.pageInfo?.count || 0}
40+
count={publicDatasetsData.datasets?.pageInfo?.count ||
41+
publicDatasetsData.advancedSearch?.pageInfo.count || 0}
3942
/>
4043
</>
4144
)

packages/openneuro-app/src/scripts/pages/front-page/aggregate-queries/use-publicDatasets-count.ts

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,31 @@ const PUBLIC_DATASETS_COUNT = gql`
1010
}
1111
`
1212

13+
const BRAIN_INITIATIVE_COUNT = gql`
14+
query AdvancedSearch($query: JSON!, $datasetType: String!) {
15+
advancedSearch(query: $query, datasetType: $datasetType) {
16+
pageInfo {
17+
count
18+
}
19+
}
20+
}
21+
`
22+
1323
const usePublicDatasetsCount = (modality?: string) => {
14-
return useQuery(PUBLIC_DATASETS_COUNT, {
15-
variables: { modality },
24+
const isNIH = modality === "NIH"
25+
26+
const query = isNIH ? BRAIN_INITIATIVE_COUNT : PUBLIC_DATASETS_COUNT
27+
const variables = isNIH
28+
? {
29+
query: {
30+
bool: { filter: [{ match: { brainInitiative: { query: "true" } } }] },
31+
},
32+
datasetType: "public",
33+
}
34+
: { modality }
35+
36+
return useQuery(query, {
37+
variables,
1638
errorPolicy: "all",
1739
})
1840
}

0 commit comments

Comments
 (0)