Skip to content

Commit

Permalink
NickAkhmetov/CAT-969 Increase homepage counts query specificity (#3593)
Browse files Browse the repository at this point in the history
* CAT-969 Increase homepage counts query specificity

* adjust query to still exclude collections without a DOI
  • Loading branch information
NickAkhmetov authored Nov 5, 2024
1 parent 604b7fe commit cb495fc
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG-cat-969.md
Original file line number Diff line number Diff line change
@@ -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.
39 changes: 34 additions & 5 deletions context/app/static/js/components/home/EntityCounts/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down

0 comments on commit cb495fc

Please sign in to comment.