Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expand available filters, give applications the ability to filter and order via ENV #128

Merged
merged 3 commits into from
Mar 5, 2024

Conversation

matt-bernhardt
Copy link
Member

@matt-bernhardt matt-bernhardt commented Mar 4, 2024

This expands the set of available filter / aggregation categories that are available for our search applications, and makes it possible for each application to customize which categories are shown, and how.

With this change, the full list of available categories are:

  • Content type
  • Contributor
  • Format
  • Language
  • Literary form
  • Source
  • Subject

Individual applications can, via an ACTIVE_FILTERS environment variable, choose which of these are shown, and in what order.

Additionally, applications can override the name of any of these categories using a separate environment variable for each category.

This work will partially address ticket GDT-128, but it cannot close until the following filters are also supported:

  • Access type
  • Place (this is likely ready to go, I'm just wanting to focus on the first seven for now)
  • Publisher
  • Year

Developer

Environment

  • All new ENV is documented in README
  • All new ENV has been added to Heroku Pipeline, Staging and Prod

Accessibility

  • ANDI or Wave has been run in accordance to
    our guide and
    all issues introduced by these changes have been resolved or opened as new
    issues (link to those issues in the Pull Request details above)
  • This change does not affect the view layer, so far as I can determine

Stakeholders

  • Stakeholder approval has been confirmed (or is not needed)
  • Stakeholder approval will come during QA

Requires database migrations?

NO

Includes new or updated dependencies?

NO

Code Reviewer

  • The commit message is clear and follows our guidelines
    (not just this pull request message)
  • There are appropriate tests covering any new functionality
  • The documentation has been updated or is unnecessary
  • The changes have been verified
  • New dependencies are appropriate or there were no changes

@mitlib mitlib temporarily deployed to timdex-ui-pi-gdt-128-fi-h5seo2 March 4, 2024 15:53 Inactive
@coveralls
Copy link

coveralls commented Mar 4, 2024

Pull Request Test Coverage Report for Build 8147243807

Details

  • 11 of 11 (100.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.01%) to 99.467%

Totals Coverage Status
Change from base Build 8146877892: 0.01%
Covered Lines: 373
Relevant Lines: 375

💛 - Coveralls

@mitlib mitlib temporarily deployed to timdex-ui-pi-gdt-128-fi-h5seo2 March 4, 2024 17:26 Inactive
@mitlib mitlib temporarily deployed to timdex-ui-pi-gdt-128-fi-h5seo2 March 4, 2024 17:32 Inactive
** Why are these changes being introduced:

This app implements only two filter / aggregation categories: content
type and source. However, others are now supported by the API:
Contributors, format, languages, literary form, and subjects. Others are
coming soon, but for now these are what is available.

** Relevant ticket(s):

* https://mitlibraries.atlassian.net/browse/gdt-128

** How does this address that need:

This updates our search model, and filter helper, to add support for the
new categories.

** Document any side effects to this change:

Because all queries now include this request for more aggregations, we
need to regenerate a number of the test cassettes.
** Why are these changes being introduced:

While the API provides a large number of possible options for users to
filter and aggregate their search results, not every instance of the
application will want to use every category (GeoData and the basic
Search application will likely use different sets, for example). One
good option for enabling these differences is to leverage environment
variables.

** Relevant ticket(s):

* https://mitlibraries.atlassian.net/browse/gdt-128

** How does this address that need:

This adds a new environment variable to the application, ACTIVE_FILTERS.
This is meant to be a list of the filter categories which should be
displayed in the application. The variable is optional - without it, the
application should include every available category, in the order they
appear in the query model.

The env variable is loaded and processed in the search controller, which
is then used to order and filter the categories returned from the API
before sending the result to the user in the UI.

The tests added in this commit demonstrate the impact of this change.

** Document any side effects to this change:

Because the env var is optional, I'm not adding it to app.json. I'm
leaning toward adding it to the Heroku pipeline, to preserve the current
behavior (only content type and source being shown).
** Why are these changes being introduced:

* The nice_labels method in the filter helper defines static names for
  each possible filter category, but the GDT project makes it likely
  that these names may need to vary by application due to the nature of
  the records available (i.e. "content type" versus "data type").

** Relevant ticket(s):

* https://mitlibraries.atlassian.net/browse/gdt-128

** How does this address that need:

* This adds support for loading the filter name from ENV, using a set of
  variables listed in the README.

** Document any side effects to this change:

This is not a side effect, but a point of hesitation. I'm unsure if we
need tests for _each_ ENV override in nice_labels. Right now I've
written one to confirm that "Content type" is the default, and one to
confirm that it can be overriden - for that category only. It feels
like a bit of overkill to test each of the seven categories (and then
need to write more tests as new categories are added to the API) - but
this leaves open the possibility that the overrides - which are not
likely to be heavily used - might break in a way that we do not realize
initially.

I take some solace in the fact that the defaults we provide are "okay",
and that there will be stakeholders watching for the overridden values -
so any future problem should be caught relatively quickly - but I'm open
to contrasting perspectives here.
@mitlib mitlib temporarily deployed to timdex-ui-pi-gdt-128-fi-h5seo2 March 4, 2024 21:28 Inactive
@matt-bernhardt matt-bernhardt marked this pull request as ready for review March 4, 2024 21:54
@jazairi jazairi self-assigned this Mar 5, 2024
Copy link
Contributor

@jazairi jazairi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work on this! This will make it much easier to add the other filters when they become available. Abstracting the config to env is a nice touch that will help us manage multiple TIMDEX apps with different filters and labels.

I agree both that it would be tiresome to test everything in nice_labels, and that it opens us up to missing a potential breaking change. In this case, I think the logic in that method is so simple that testing one filter as a sample is fine for now. As you note, it's written to fall back on reasonable labels, anyway. It seems to be that the absolute worst case is that a new filter label is not defined at all, in which case it will fall back to the GraphQL field name, which doesn't feel particularly dangerous.

A minimally painful way to test everything could be to just add all the label to those two tests, so if something is off with anything in the nice_labels hash, the test fails and alerts us to the issue. That may be something to consider we've added the last of the filters. For now, this feels like adequate coverage.

Thanks for the excellent work, and for going above and beyond the requirements!

@jazairi
Copy link
Contributor

jazairi commented Mar 5, 2024

One more thing to add, in case you mention this detail in an amended commit message: GDT-128 can actually close without the access type filter. That one has its own ticket (GDT-140), as it's a bit different from the others.

@matt-bernhardt matt-bernhardt merged commit dbd64b9 into main Mar 5, 2024
4 of 5 checks passed
@matt-bernhardt matt-bernhardt deleted the gdt-128-filters-list branch March 5, 2024 20:15
matt-bernhardt added a commit that referenced this pull request Mar 12, 2024
** 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants