From 1c0b07c1c89c6af5f63db29870624a24bb44d438 Mon Sep 17 00:00:00 2001 From: Matthew Bernhardt Date: Mon, 11 Mar 2024 18:04:34 -0400 Subject: [PATCH] Add places to list of filters and aggregations ** Why are these changes being introduced: * The TIMDEX API has added support for a Places filter and aggregation, so the UI should be extended to take advantage of this. ** Relevant ticket(s): * https://mitlibraries.atlassian.net/browse/post-128 ** How does this address that need: * This builds on the work from #128 and #131, to include the Places feature in our displayed filters and aggregations. ** Document any side effects to this change: * These changes will require that our test cassettes are re-generated, which will happen in the next commit. --- README.md | 1 + app/helpers/filter_helper.rb | 1 + app/models/enhancer.rb | 4 ++-- app/models/query_builder.rb | 4 ++-- app/models/timdex_search.rb | 6 ++++++ 5 files changed, 12 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index e330e386..a36e7b77 100644 --- a/README.md +++ b/README.md @@ -57,6 +57,7 @@ change as part of the work. - `FILTER_FORMAT`: The name to use instead of "Format" for that filter / aggregation. - `FILTER_LANGUAGE`: The name to use instead of "Language" for that filter / aggregation. - `FILTER_LITERARY_FORM`: The name to use instead of "Literary form" for that filter / aggregation. +- `FILTER_PLACE`: The name to use instead of "Place" for that filter / aggregation. - `FILTER_SOURCE`: The name to use instead of "Source" for that filter / aggregation. - `FILTER_SUBJECT`: The name to use instead of "Subject" for that filter / aggregation. - `GDT`: Enables features related to geospatial data discovery. Setting this variable with any value will trigger GDT diff --git a/app/helpers/filter_helper.rb b/app/helpers/filter_helper.rb index 2dafa006..8816cb54 100644 --- a/app/helpers/filter_helper.rb +++ b/app/helpers/filter_helper.rb @@ -26,6 +26,7 @@ def nice_labels formatFilter: ENV.fetch('FILTER_FORMAT', 'Format'), languagesFilter: ENV.fetch('FILTER_LANGUAGE', 'Language'), literaryFormFilter: ENV.fetch('FILTER_LITERARY_FORM', 'Literary form'), + placesFilter: ENV.fetch('FILTER_PLACE', 'Place'), sourceFilter: ENV.fetch('FILTER_SOURCE', 'Source'), subjectsFilter: ENV.fetch('FILTER_SUBJECT', 'Subject') } diff --git a/app/models/enhancer.rb b/app/models/enhancer.rb index 3b40c7bf..2a7028d9 100644 --- a/app/models/enhancer.rb +++ b/app/models/enhancer.rb @@ -2,8 +2,8 @@ class Enhancer attr_accessor :enhanced_query QUERY_PARAMS = %i[q citation contentType contributors fundingInformation identifiers locations subjects title].freeze - FILTER_PARAMS = %i[contentTypeFilter contributorsFilter formatFilter languagesFilter literaryFormFilter sourceFilter - subjectsFilter].freeze + FILTER_PARAMS = %i[contentTypeFilter contributorsFilter formatFilter languagesFilter literaryFormFilter placesFilter + sourceFilter subjectsFilter].freeze # accepts all params as each enhancer may require different data def initialize(params) diff --git a/app/models/query_builder.rb b/app/models/query_builder.rb index 6870879a..3d6551a4 100644 --- a/app/models/query_builder.rb +++ b/app/models/query_builder.rb @@ -3,8 +3,8 @@ class QueryBuilder RESULTS_PER_PAGE = 20 QUERY_PARAMS = %w[q citation contributors fundingInformation identifiers locations subjects title].freeze - FILTER_PARAMS = %i[contentTypeFilter contributorsFilter formatFilter languagesFilter literaryFormFilter sourceFilter - subjectsFilter].freeze + FILTER_PARAMS = %i[contentTypeFilter contributorsFilter formatFilter languagesFilter literaryFormFilter placesFilter + sourceFilter subjectsFilter].freeze def initialize(enhanced_query) @query = {} diff --git a/app/models/timdex_search.rb b/app/models/timdex_search.rb index dcd4f0c5..1691342f 100644 --- a/app/models/timdex_search.rb +++ b/app/models/timdex_search.rb @@ -19,6 +19,7 @@ class TimdexSearch < TimdexBase $formatFilter: [String!] $languagesFilter: [String!] $literaryFormFilter: String + $placesFilter: [String!] $sourceFilter: [String!] $subjectsFilter: [String!] ) { @@ -38,6 +39,7 @@ class TimdexSearch < TimdexBase formatFilter: $formatFilter languagesFilter: $languagesFilter literaryFormFilter: $literaryFormFilter + placesFilter: $placesFilter sourceFilter: $sourceFilter subjectsFilter: $subjectsFilter ) { @@ -86,6 +88,10 @@ class TimdexSearch < TimdexBase key docCount } + places { + key + docCount + } source { key docCount