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

Update Primo author link encoding #1400

Merged
merged 2 commits into from
Jan 21, 2025
Merged

Conversation

JPrevost
Copy link
Member

Why are these changes being introduced:

  • Author linking does not encode the author names which sometimes made the links to Primo not work as expected

Relevant ticket(s):

How does this address that need:

  • Encodes the author component of the URL

Document any side effects to this change:

I didn't look at anything else as we so rarely touch this code I don't remember how a lot of it works and I didn't want to pull strings that caused much more work than we intended at this time.

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

Why are these changes being introduced:

* Author linking does not encode the author names which sometimes made
  the links to Primo not work as expected

Relevant ticket(s):

* https://mitlibraries.atlassian.net/browse/PW-132

How does this address that need:

* Encodes the author component of the URL

Document any side effects to this change:

I didn't look at anything else as we so rarely touch this code I don't
remember how a lot of it works and I didn't want to pull strings that
caused much more work than we intended at this time.
@mitlib mitlib temporarily deployed to mit-bento-pr-1400 January 21, 2025 19:42 Inactive
ENV.fetch('PRIMO_VID', nil)].join
end

def clean_author(author)
Copy link
Member Author

Choose a reason for hiding this comment

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

I exctrated this out thinking the solution may have been more complex than just encoding. I left it as it's own method as author_link has quite a bit going on. I'm not sure if this makes things better or worse. I'm happy to collapse it or leave it as is.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm fine with making this its own method, but what do you think about changing the method name? clean_author might be confusing alongside sanitize_authors. Maybe encode_author, or something to that effect?

Copy link
Member Author

Choose a reason for hiding this comment

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

Great idea. I didn't even notice the confusing naming until you mentioned it. Thanks!

@coveralls
Copy link

coveralls commented Jan 21, 2025

Coverage Status

coverage: 99.127% (+0.004%) from 99.123%
when pulling 9e51fd8 on pw-132-ampersands-in-authors
into 2d99b5e on main.

@jazairi jazairi self-assigned this Jan 21, 2025
Comment on lines -82 to 94
'https://mit.primo.exlibrisgroup.com/discovery/search?query=creator,exact,Rudolph, J.&tab=all&search_scope=all&vid=FAKE_PRIMO_VID'],
'https://mit.primo.exlibrisgroup.com/discovery/search?query=creator,exact,Rudolph%2C%20J.&tab=all&search_scope=all&vid=FAKE_PRIMO_VID'],
result.authors.first
end

test 'multiple authors in a single element are appropriately parsed' do
result = monkeys['results'].second
assert_not_equal ['Beran, Michael J ; Smith, J. David'], result.authors.first.first
assert_equal ['Beran, Michael J',
'https://mit.primo.exlibrisgroup.com/discovery/search?query=creator,exact,Beran, Michael J&tab=all&search_scope=all&vid=FAKE_PRIMO_VID'],
'https://mit.primo.exlibrisgroup.com/discovery/search?query=creator,exact,Beran%2C%20Michael%20J&tab=all&search_scope=all&vid=FAKE_PRIMO_VID'],
result.authors.first
assert_equal ['Smith, J. David',
'https://mit.primo.exlibrisgroup.com/discovery/search?query=creator,exact,Smith, J. David&tab=all&search_scope=all&vid=FAKE_PRIMO_VID'],
'https://mit.primo.exlibrisgroup.com/discovery/search?query=creator,exact,Smith%2C%20J.%20David&tab=all&search_scope=all&vid=FAKE_PRIMO_VID'],
result.authors.second
Copy link
Member Author

Choose a reason for hiding this comment

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

I just noticed that many things change automatically with my local styles check on save. Sorry for the noise. These are the only intentional changes to this file

Copy link
Contributor

@jazairi jazairi left a comment

Choose a reason for hiding this comment

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

Thanks for pulling this and applying the fix! I added a comment in the thread you started about where to put the URI encoding. I wouldn't ordinarily suggest such a small change, but in this case it might make this model a bit easier to grok the next time we come back to this repo (which hopefully be never).

ENV.fetch('PRIMO_VID', nil)].join
end

def clean_author(author)
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm fine with making this its own method, but what do you think about changing the method name? clean_author might be confusing alongside sanitize_authors. Maybe encode_author, or something to that effect?

Code review identified two method names that were likely to be misleading in the future. This
updates the newly introduced method to be less similar to the existing method.
@JPrevost JPrevost temporarily deployed to mit-bento-pr-1400 January 21, 2025 20:18 Inactive
@JPrevost JPrevost requested a review from jazairi January 21, 2025 20:19
@JPrevost JPrevost merged commit fbdea98 into main Jan 21, 2025
4 checks passed
@JPrevost JPrevost deleted the pw-132-ampersands-in-authors branch January 21, 2025 20:59
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