Skip to content

Trigger OpenAlex lookups on articles only#392

Open
jazairi wants to merge 1 commit into
mainfrom
use-503
Open

Trigger OpenAlex lookups on articles only#392
jazairi wants to merge 1 commit into
mainfrom
use-503

Conversation

@jazairi
Copy link
Copy Markdown
Contributor

@jazairi jazairi commented May 15, 2026

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:

  • 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.

Side effects of this change:

We'll see fewer OpenAlex links, but hopefully more accurate ones.

Developer

Accessibility
  • ANDI or WAVE has been run in accordance to our guide.
  • This PR contains no changes to the view layer.
  • New issues flagged by ANDI or WAVE have been resolved.
  • New issues flagged by ANDI or WAVE have been ticketed (link in the Pull Request details above).
  • No new accessibility issues have been flagged.
New ENV
  • All new ENV is documented in README.
  • All new ENV has been added to Heroku Pipeline, Staging and Prod.
  • ENV has not changed.
Approval beyond code review
  • UXWS/stakeholder approval has been confirmed.
  • UXWS/stakeholder review will be completed retroactively.
  • UXWS/stakeholder review is not needed.
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
  • I have confirmed that the code works as intended.
  • Any CodeClimate issues have been fixed or confirmed as
    added technical debt.
Documentation
  • The commit message is clear and follows our guidelines
    (not just this pull request message).
  • The documentation has been updated or is unnecessary.
  • New dependencies are appropriate or there were no changes.
Testing
  • There are appropriate tests covering any new functionality.
  • No additional test coverage is required.

@coveralls
Copy link
Copy Markdown

coveralls commented May 15, 2026

Coverage Report for CI Build 25943955503

Coverage increased (+0.005%) to 98.37%

Details

  • Coverage increased (+0.005%) from the base build.
  • Patch coverage: 4 of 4 lines across 2 files are fully covered (100%).
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 1411
Covered Lines: 1388
Line Coverage: 98.37%
Coverage Strength: 68.79 hits per line

💛 - Coveralls

@qltysh
Copy link
Copy Markdown

qltysh Bot commented May 15, 2026

❌ 1 blocking issue (1 total)

Tool Category Rule Count
rubocop Lint Assignment Branch Condition size for libkey is too high. [<4, 17, 6> 18.47/17] 1

@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]
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Assignment Branch Condition size for libkey is too high. [<4, 17, 6> 18.47/17] [rubocop:Metrics/AbcSize]

Comment thread app/helpers/results_helper.rb Outdated
@mitlib mitlib temporarily deployed to timdex-ui-pi-use-503-j6vxneqfw May 15, 2026 20:07 Inactive
@jazairi jazairi requested a review from Copilot May 15, 2026 21:49
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 format through _trigger_libkey partial → /libkey endpoint → ThirdironController#libkeylibkey.html.erb.
  • Gate OpenAlex rendering in both _result_primo.html.erb (OA_ALWAYS branch) and libkey.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.

Comment thread app/views/thirdiron/libkey.html.erb Outdated
Comment thread app/helpers/results_helper.rb Outdated
Comment thread app/helpers/results_helper.rb Outdated
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.
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