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

Add search summary panel and full filter support #117

Merged
merged 1 commit into from
Feb 20, 2024

Conversation

jazairi
Copy link
Contributor

@jazairi jazairi commented Feb 16, 2024

Why these changes are being introduced:

It would be helpful if users could see what filters they've applied to a search directly below the search bar, which would also provide another path to remove filters.

Relevant ticket(s):

https://mitlibraries.atlassian.net/browse/GDT-142

How this addresses that need:

This provides the requested panel. We had been calling this a "filter removal" panel, but I ended up naming the partial search_summary to avoid any confusion with the filter sidebar. However, the currently displayed data has the filter-removal class, because it's likely we will want to show advanced search terms here, too (possibly just for screen readers).

While working on this, it occurred to me that the existing TIMDEX UI filter implementation is incomplete. It pulls in the aggregation names and uses those as the internal filter names. This works fine for the existing contentType and source filters, but it will cause a name collision for filters that also exist as regular search inputs (e.g. contributors vs. contributorsFilter). Since we will be adding more aggregations and filters soon, it makes sense to fix this problem now.

Side effects of these changes:

  • The "You searched for" list has been removed, as this feature replaces it. As mentioned above, we will likely want to provide that information in some manner in the search summary, but that will require some discussion with Darcy, who is out-of-office at the moment.
  • Filter keys are now cast as symbols throughout the application. Previously, they would be strings in some places and symbols in others. I found that confusing, but if this change is even more confusing, I'm happy to revert it.
  • A few tests have been skipped due to the removal of the "You searched for list". I chose not to delete them in case we reintroduce that feature in the near future.
  • Most of the cassettes have been regenerated, due to changes to the TimdexSearch model.

Developer

  • All new ENV is documented in README
  • All new ENV has been added to Heroku Pipeline, Staging and Prod
  • 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)
  • Stakeholder approval has been confirmed (or is not needed)

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

Requires database migrations?

NO

Includes new or updated dependencies?

NO

@mitlib mitlib temporarily deployed to timdex-ui-pi-gdt-142-fi-yi3pdo February 16, 2024 20:47 Inactive
@coveralls
Copy link

coveralls commented Feb 16, 2024

Pull Request Test Coverage Report for Build 7978579909

Details

  • 0 of 13 (100.0%) changed or added relevant lines in 4 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.008%) to 99.452%

Totals Coverage Status
Change from base Build 7892634244: 0.008%
Covered Lines: 363
Relevant Lines: 365

💛 - Coveralls

@JPrevost JPrevost self-assigned this Feb 16, 2024
@jazairi jazairi force-pushed the gdt-142-filter-removal-panel branch from 979efa2 to 4e47776 Compare February 16, 2024 20:56
@jazairi jazairi temporarily deployed to timdex-ui-pi-gdt-142-fi-yi3pdo February 16, 2024 20:56 Inactive
@jazairi jazairi temporarily deployed to timdex-ui-pi-gdt-142-fi-yi3pdo February 16, 2024 22:25 Inactive
@mitlib mitlib temporarily deployed to timdex-ui-pi-gdt-142-fi-eqfd7k February 20, 2024 14:27 Inactive
Copy link
Member

@JPrevost JPrevost left a comment

Choose a reason for hiding this comment

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

I'm not really asking for changes so much as asking for confirmation on next steps prior to approval as this works great, but the wording is really difficult for me to accept without knowing what we're going to do about it :)

@@ -33,7 +33,7 @@ def extract_filters(response)
aggs = response&.data&.search&.to_h&.dig('aggregations')
return if aggs.blank?

aggs.select { |_, agg_values| agg_values.present? }
aggs.select { |_, agg_values| agg_values.present? }.transform_keys { |key| (key.dup << 'Filter').to_sym }
Copy link
Member

Choose a reason for hiding this comment

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

Does this feel like a workaround to a deficiency in our API? Or is this something only our UI is likely to encounter?

It feels like we should be returning our aggregations using the same terminology as we use to apply them. So instead of returning source we should return that aggregation as sourceFilter so it is clearer how to use the data. Thoughts?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Possibly. I hate this code, and manipulating the response this much in the UI certainly feels like a workaround, but I don't know if I'm convinced we should change our aggregation names. Since they're not filter/filters aggregations, naming them as such might be confusing to other consumers. Less confusing than having different names for the corresponding aggs, though? I'm not sure.

app/models/query_builder.rb Show resolved Hide resolved
@@ -272,6 +272,8 @@ class SearchControllerTest < ActionDispatch::IntegrationTest

# Advanced search behavior
test 'advanced search by keyword' do
skip("We no longer display a list of search terms in the UI; leaving this in in case we decide to reintroduce" \
Copy link
Member

Choose a reason for hiding this comment

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

I know you brought this to the team last week, but after seeing in action, I'm fairly hesitant to remove this feature as it reads very weird the way it is implemented as it feels like it sits halfway between "these are all the things you searched for" and "these are the filters that are applied but please look at the form above for the rest of the values you searched for". i.e. the words say one thing but the implementation is the other... which is awkward.

My preference would be to label it in the way it is currently functioning (Applied filters: ...) as that feels like the easiest solution for now even if it doesn't match the requested wording. The alternative would be to add all of the various searchable bits to this new panel which honestly feels like a better longterm direction.

If there is a ticket to resolve this distinction after talking with UX when they are back from vacation, I could probably get over this :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'd strongly prefer changing the label to Applied filters. In my opinion, the "You searched for" list is redundant with the expanded form. (And, honestly, I'm not sure what these tests are confirming, except that these fields show up in the enhanced query.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also, sprint planning reminded me that I created a ticket to figure out what we want to do with advanced search terms: https://mitlibraries.atlassian.net/browse/GDT-196

@jazairi jazairi force-pushed the gdt-142-filter-removal-panel branch from b5e8df1 to 5a6cc28 Compare February 20, 2024 16:13
@jazairi jazairi requested a review from JPrevost February 20, 2024 16:13
@jazairi jazairi temporarily deployed to timdex-ui-pi-gdt-142-fi-eqfd7k February 20, 2024 16:13 Inactive
@jazairi jazairi force-pushed the gdt-142-filter-removal-panel branch from 5a6cc28 to 479266f Compare February 20, 2024 18:49
@jazairi jazairi temporarily deployed to timdex-ui-pi-gdt-142-fi-eqfd7k February 20, 2024 18:49 Inactive
Why these changes are being introduced:

It would be helpful if users could see what filters they've
applied to a search directly below the search bar, which would
also provide another path to remove filters.

Relevant ticket(s):

https://mitlibraries.atlassian.net/browse/GDT-142
https://mitlibraries.atlassian.net/browse/GDT-196

How this addresses that need:

This provides the requested panel. We had been calling this a
"filter removal" panel, but I ended up naming the partial
`search_summary` to avoid any confusion with the filter
sidebar. However, the currently displayed data has the
`filter-removal` class, because it's possible we will want to
show advanced search terms here, too.

While working on this, it occurred to me that the existing TIMDEX
UI filter implementation is incomplete. It pulls in the aggregation
names and uses those as the internal filter names. This works fine
for the existing `contentType` and `source` filters, but it will
cause a name collision for filters that also exist as regular
search inputs (e.g. `contributors` vs. `contributorsFilter`). Since
we will be adding more aggregations and filters soon, it makes sense
to fix this problem now.

Because this only lists filters at present, we've changed the
label from 'You searched for' to 'Applied filters'. This is
subject to change.

Side effects of these changes:

* The "You searched for" list has been removed, as this feature
replaces it. As mentioned above, we will likely want to provide
that information in some manner in the search summary, but that
will require some discussion with Darcy, who is out-of-office at
the moment.
* Filter keys are now cast as symbols throughout the application.
Previously, they would be strings in some places and symbols in
others. I found that confusing, but if this change is even more
confusing, I'm happy to revert it.
* A few tests have been skipped due to the removal of the "You
searched for list". I chose not to delete them in case we
reintroduce that feature in the near future.
* Most of the cassettes have been regenerated, due to changes to
the `TimdexSearch` model.

Address code review feedback
@jazairi jazairi force-pushed the gdt-142-filter-removal-panel branch from 479266f to 02db6ad Compare February 20, 2024 18:57
@jazairi jazairi temporarily deployed to timdex-ui-pi-gdt-142-fi-eqfd7k February 20, 2024 18:57 Inactive
@jazairi jazairi merged commit 4783334 into main Feb 20, 2024
5 checks passed
@jazairi jazairi deleted the gdt-142-filter-removal-panel branch February 20, 2024 19:01
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