diff --git a/CHANGELOG-cat-969.md b/CHANGELOG-cat-969.md new file mode 100644 index 0000000000..08c48e56ef --- /dev/null +++ b/CHANGELOG-cat-969.md @@ -0,0 +1,2 @@ +- Adjust homepage queries to exclude donors/samples without descended datasets. +- Adjust homepage queries to exclude datasets in a non-QA/Published state. diff --git a/context/app/static/js/components/home/EntityCounts/hooks.ts b/context/app/static/js/components/home/EntityCounts/hooks.ts index 32ffd2ec33..46317036a3 100644 --- a/context/app/static/js/components/home/EntityCounts/hooks.ts +++ b/context/app/static/js/components/home/EntityCounts/hooks.ts @@ -5,11 +5,40 @@ const entityCountsQuery: SearchRequest = { size: 0, query: { bool: { - // Only include collections with a DOI in count - should: [ - { bool: { must_not: { term: { 'entity_type.keyword': 'Collection' } } } }, - { bool: { must: [{ exists: { field: 'doi_url' } }, { exists: { field: 'registered_doi' } }] } }, - ], + // Exclude invalid/new datasets from count + // using `must_not` for this allows entities without a mapped status to still be matched + must_not: { + terms: { + 'mapped_status.keyword': ['Invalid', 'Error', 'New', 'Processing', 'Submitted'], + }, + }, + // Nested musts are necessary to form an AND of ORs (i.e. a MUST of SHOULDs) + must: { + bool: { + must: [ + { + // Exclude donors/samples with no associated datasets + bool: { + should: [ + // Either not a donor/sample + { bool: { must_not: { terms: { 'entity_type.keyword': ['Donor', 'Sample'] } } } }, + // or has at least one descended dataset + { bool: { must: { exists: { field: 'descendant_counts.entity_type.Dataset' } } } }, + ], + }, + }, + { + // Only include collections with a DOI in count + bool: { + should: [ + { bool: { must_not: { term: { 'entity_type.keyword': 'Collection' } } } }, + { bool: { must: [{ exists: { field: 'doi_url' } }, { exists: { field: 'registered_doi' } }] } }, + ], + }, + }, + ], + }, + }, }, }, aggs: {