Conversation
Why these changes are being introduced: There is a need to selectively enable the Primo NDE feature. Relevant ticket(s): - [USE-367](https://mitlibraries.atlassian.net/browse/USE-367) How this addresses that need: This adds a Primo NDE feature that allows us to enable NDE links for searches and full records. Primo links are now abstracted to a Primo Link Builder to reduce duplication. Side effects of this change: The Primo Link Builder is the latest example of a service being stored in the `models/` directory. We may want to consider moving our services to a separate directory for clarity's sake.
Pull Request Test Coverage Report for Build 22870066925Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
❌ 2 blocking issues (2 total)
|
JPrevost
left a comment
There was a problem hiding this comment.
Added a few questions/comments to consider before we wrap this up
| search_scope: 'all', | ||
| vid: ENV.fetch('PRIMO_VID') | ||
| }) | ||
| PrimoLinkBuilder.new(query_term: params[:q]).search_link |
There was a problem hiding this comment.
Nice use of the builder pattern. It does a great job consolidating this logic and making it more testable.
test/helpers/search_helper_test.rb
Outdated
| test 'primo_search_url generates correct Primo URL' do | ||
| query = 'machine learning' | ||
| expected_url = 'https://mit.primo.exlibrisgroup.com/discovery/search?query=any%2Ccontains%2Cmachine+learning&vid=01MIT_INST%3AMIT' | ||
| expected_url = 'https://mit.primo.exlibrisgroup.com/discovery/search?query=any%2Ccontains%2Cmachine+learning&tab=all&search_scope=all&vid=01MIT_INST%3AMIT' |
There was a problem hiding this comment.
Were the links returned by this helper previously incorrect?
There was a problem hiding this comment.
Not exactly. The expected url string excluded a couple of params, which I don't think are necessary, but it made sense to me to include them since Primo is such a black box.
| # builder.full_record_link | ||
| # # => "https://mit.primo.exlibrisgroup.com/discovery/fulldisplay?docid=alma123&..." | ||
| class PrimoLinkBuilder | ||
| def initialize(query_term: nil, record_id: nil, context: nil) |
There was a problem hiding this comment.
It would be helpful to explain these input variables. While query_term and record_id are easily understandable, I'm genuinely not sure what context is.
There was a problem hiding this comment.
Context is used for the display endpoint only and indicates whether it's Alma/local ("L") or CDI (uhh...something else). Will document.
app/models/primo_link_builder.rb
Outdated
| # @param tab [String] The Primo tab parameter (default: 'all') | ||
| # @param search_scope [String] The search scope (default: 'all') | ||
| # @return [String] The complete search URL | ||
| def search_link(tab: 'all', search_scope: 'all') |
There was a problem hiding this comment.
Is there a reason the search_link and full_record_link methods use different defaults? Is it possible they both might want to default to whatever the tab is set at unless it is not set then use all like ENV.fetch('PRIMO_TAB', 'all)?
There is good documentation as to what tab, scope, and vid do in our primo_search model. I'm not sure if the best play is to note that for details as to what they are to see that model or to copy it here. Neither are ideal.
There was a problem hiding this comment.
Good point. In fact, both tab and scope can probably come from env.
| end | ||
| end | ||
|
|
||
| test 'full_record_link generates production URL by default' do |
There was a problem hiding this comment.
discovery and production being used interchangeably in test names might confuse us once NDE becomes production. Suggestion: update this test to use discovery URL naming
| # Test NDE link generation | ||
| require 'test_helper' | ||
|
|
||
| class PrimoLinkBuilderTest < ActiveSupport::TestCase |
There was a problem hiding this comment.
I suspect the intent of testing the way we are here is to avoid fragile tests, but it makes me nervous not to have any full link testing. I think most of these are fine as is, but maybe one more test for each type of link "search_link|full_record_link generates a full link as expected" or something?
|
@JPrevost Let me know if the updated docs are better or worse. (I'm not sure one way or the other.) |
Why these changes are being introduced:
There is a need to selectively enable the Primo NDE feature.
Relevant ticket(s):
How this addresses that need:
This adds a Primo NDE feature that allows us to enable NDE links for searches and full records. Primo links are now abstracted to a Primo Link Builder to reduce duplication.
Side effects of this change:
The Primo Link Builder is the latest example of
a service being stored in the
models/directory. We may want to consider moving our services to aseparate directory for clarity's sake.
Developer
Accessibility
New ENV
Approval beyond code review
Additional context needed to review
See the ticket for example NDE links. The links in the PR build, which has the feature enabled, should match these.
Code Reviewer
Code
added technical debt.
Documentation
(not just this pull request message).
Testing