Skip to content

Commit

Permalink
Add places to list of filters and aggregations
Browse files Browse the repository at this point in the history
** 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.
  • Loading branch information
matt-bernhardt committed Mar 12, 2024
1 parent f82c87a commit 1c0b07c
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions app/helpers/filter_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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')
}
Expand Down
4 changes: 2 additions & 2 deletions app/models/enhancer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions app/models/query_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}
Expand Down
6 changes: 6 additions & 0 deletions app/models/timdex_search.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class TimdexSearch < TimdexBase
$formatFilter: [String!]
$languagesFilter: [String!]
$literaryFormFilter: String
$placesFilter: [String!]
$sourceFilter: [String!]
$subjectsFilter: [String!]
) {
Expand All @@ -38,6 +39,7 @@ class TimdexSearch < TimdexBase
formatFilter: $formatFilter
languagesFilter: $languagesFilter
literaryFormFilter: $literaryFormFilter
placesFilter: $placesFilter
sourceFilter: $sourceFilter
subjectsFilter: $subjectsFilter
) {
Expand Down Expand Up @@ -86,6 +88,10 @@ class TimdexSearch < TimdexBase
key
docCount
}
places {
key
docCount
}
source {
key
docCount
Expand Down

0 comments on commit 1c0b07c

Please sign in to comment.