Conversation
Coverage Report for CI Build 25943955503Coverage increased (+0.005%) to 98.37%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
❌ 1 blocking issue (1 total)
|
| @libkey = Libkey.lookup(type: params[:type], identifier: params[:identifier]) | ||
| @doi = params[:type] == 'doi' ? params[:identifier] : nil | ||
| @pmid = params[:type] == 'pmid' ? params[:identifier] : nil | ||
| @format = params[:format] |
There was a problem hiding this comment.
Pull request overview
This PR restricts OpenAlex fulfillment-link lookups to article-type items only, addressing USE-503 where non-article content (Research Databases, Journals, eBooks, etc.) was getting misleading OpenAlex links. It introduces an is_article? helper, threads the record's format through the LibKey trigger partial and controller, and gates both the FEATURE_OA_ALWAYS Primo trigger and the LibKey-empty fallback on the format being article-like.
Changes:
- Add
is_article?helper (case-insensitive substring match on "article") with tests. - Pass
formatthrough_trigger_libkeypartial →/libkeyendpoint →ThirdironController#libkey→libkey.html.erb. - Gate OpenAlex rendering in both
_result_primo.html.erb(OA_ALWAYS branch) andlibkey.html.erb(empty-LibKey fallback) on article format.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| app/helpers/results_helper.rb | New is_article? predicate that powers the article-only filter. |
| app/views/search/_result_primo.html.erb | Passes format to LibKey partial and gates OA_ALWAYS OpenAlex rendering on is_article?. |
| app/views/search/_trigger_libkey.html.erb | Builds the /libkey URL via a params hash, adding format when present. |
| app/controllers/thirdiron_controller.rb | Reads params[:format] into @format for the view. |
| app/views/thirdiron/libkey.html.erb | Adds article-only condition to the empty-LibKey OpenAlex fallback (duplicates helper logic inline). |
| test/helpers/results_helper_test.rb | Tests for is_article? covering case variants, non-article formats, and blank/nil. |
| test/controllers/thirdiron_controller_test.rb | Updates existing tests to pass format=Article and adds a non-article case asserting no OpenAlex container. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Why these changes are being introduced: OpenAlex lookups currently triggers on non-article content types (e.g., Research Databases, Journals, eBooks). This can result in incorrect or misleading fulfillment links. Relevant ticket(s): - [USE-503](https://mitlibraries.atlassian.net/browse/USE-503) How this addresses that need: - Adds article? helper to check if format matches 'article' (catches Article, Magazine Article, Newsletter Article, etc.) - Passes format parameter through LibKey request/view chain Side effects of this change: We'll see fewer OpenAlex links, but hopefully more accurate ones.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why these changes are being introduced:
OpenAlex lookups currently triggers on non-article content types
(e.g., Research Databases, Journals, eBooks). This can result in
incorrect or misleading fulfillment links.
Relevant ticket(s):
How this addresses that need:
(catches Article, Magazine Article, Newsletter Article, etc.)
Side effects of this change:
We'll see fewer OpenAlex links, but hopefully more accurate ones.
Side effects of this change:
We'll see fewer OpenAlex links, but hopefully more accurate ones.
Developer
Accessibility
New ENV
Approval beyond code review
Additional context needed to review
E.g., if the PR includes updated dependencies and/or data
migration, or how to confirm the feature is working.
Code Reviewer
Code
added technical debt.
Documentation
(not just this pull request message).
Testing