-
Notifications
You must be signed in to change notification settings - Fork 0
Implement unified 'all' search tab #274
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
Conversation
Pull Request Test Coverage Report for Build 19340970745Details
💛 - Coveralls |
JPrevost
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice initial implementation of this feature!
Before we merge I think we should decide what to do with geodata in terms of set_active_tab. We should either not set it, allow it to be valid, or only allow it to be valid in geodata mode.
| assert_select '#tab-to-target' do | ||
| refute_select '[value=?]', 'primo' | ||
| assert_select '[value=?]', 'geodata' | ||
| assert_select '[value=?]', 'all' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test name and assertions are no longer aligned. The test says to expect geodata but shows all is returned. See my other comment about our need to confirm our intent with the geodata logic in set_active_tab which will affect whether we change the test name or assertions here.
| def set_active_tab | ||
| @active_tab = if Feature.enabled?(:geodata) | ||
| # Determine which tab to load - default to primo unless gdt is enabled | ||
| 'geodata' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This value can never be achieved unless we include it in the valid_tab? method. I believe a few tests were changed to remove geodata as a possible tab value. I could probably be swayed to not set geodata as a tab as it isn't actually currently a tab, but if we are doing that we should remove the logic that actually tries to set it as an invalid value :)
My reasoning for setting a geodata tab in the first place was possibly flawed and I'm open to removing this first condition and running in geodata mode to confirm if it is actually needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it still works because we're not calling valid_tab? in that branch of the condition. But either way, it's confusing enough that it should be refactored. I'll consider alternatives.
| private | ||
|
|
||
| def valid_tab?(tab) | ||
| %w[primo timdex all].include?(tab) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternatively to removing the first condition in the active_tab logic, we should instead set geodata as a valid tab. I think in real-world scenarios that is fine but when changing your local or a pr build between geodata and normal you may end up in wonky states where the cookie says to load an invalid tab?
I think I'd either remove the geodata logic from active_tab or keep it and add which tabs are valid here in each mode with a feature flag. I'm happy to chat if it would be helpful to work through the edge cases we are trying to support in real time.
| assert_equal cookies[:last_tab], 'all' | ||
| end | ||
|
|
||
| test 'set_active_tab ignores invalid cookie value and uses default' do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I appreciate this test even though it may feel like it isn't a state we can get in to. I suspect we'll change tab configurations a few times over the next few months and this will be critical to make sure user browsers can handle it. 🍻
| # Zipper merge results from both APIs | ||
| primo_results = primo_data[:results] || [] | ||
| timdex_results = timdex_data[:results] || [] | ||
| @results = primo_results.zip(timdex_results).flatten.compact |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✨
|
@JPrevost I think the latest commit makes the GeoData toggling logic a bit clearer. Could you confirm? In the process, I removed a bunch of instances of 'gdt/GDT', so apologies that it touches more files than necessary. |
JPrevost
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jazairi Those changes work for me.
I'm going to hold off on formal approval until the rebase with the active tab logic Matt just merged as I know there is a merge conflict and want to do a click test of the resolved merge before approval.
Why these changes are being introduced: A key requirement for USE UI is a tab that combines results from multiple sources. The current interface requires users to search each source separately, creating friction in the discovery process. Relevant ticket(s): - [USE-176](https://mitlibraries.atlassian.net/browse/USE-176) - [USE-177](https://mitlibraries.atlassian.net/browse/USE-177) How this addresses that need: - Add new 'all' tab as the default search mode - Implement parallel API fetching using Ruby threads to query both Primo and TIMDEX simultaneously - Use zipper merge pattern to interleave results from both sources - Update view templates to render source-specific results for 'all' tab - Add tab parameter validation to prevent invalid selections - Change default tab from 'primo' to 'all' in ApplicationController Side effects of this change: - Default search behavior changes from Primo-only to combined results - A `valid_tab?` method now confirms that the tab param is one of 'primo,' 'timdex', or 'all' - Possible increased server load due to parallel API calls (I haven't confirmed this, but it seems likely) - Some peripherally related tests have been updated to account for new behavior - Pagination is not yet implemented (this will be done in USE-178 and USE-179)
Why these changes are being introduced: With the implementation of the 'all' tab, which includes a `valid_tab?` method, it's become confusing as to how GeoData fits into the tab system. We currently treat it as a tab, but it's also treated as a feature. Relevant ticket(s): - [USE-176](https://mitlibraries.atlassian.net/browse/USE-176) - [USE-177](https://mitlibraries.atlassian.net/browse/USE-177) How this addresses that need: This normalizes the GeoData feature flagging in the controller, such that we only check for `Feature.enabled?` when toggling GeoData, rather than a combination of `active_tab` and the `Feature` model. Side effects of this change: Remaining instances where 'GeoData/geodata' was referred to as 'GDT/gdt' have been updated to use the actual property name.
|
@JPrevost The latest commit includes a rebase of Matt's work. |
JPrevost
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
![]()
Why these changes are being introduced:
A key requirement for USE UI is a tab that combines results from multiple sources. The current interface requires users to search each source separately, creating friction in the discovery process.
Relevant ticket(s):
How this addresses that need:
Side effects of this change:
valid_tab?method now confirms that the tab param is one of 'primo,' 'timdex', or 'all'Developer
Accessibility
New ENV
Approval beyond code review
Additional context needed to review
Some functionality to confirm:
Code Reviewer
Code
added technical debt.
Documentation
(not just this pull request message).
Testing