Skip to content

Conversation

@JPrevost
Copy link
Member

@JPrevost JPrevost commented Dec 2, 2025

Why are these changes being introduced:

  • This information is useful to users to understand if an item is available for checkout or needs to be requested.

Relevant ticket(s):

How does this address that need:

  • Creates a helper method to format availability information
  • Updates the result partial to display availability information

Document any side effects to this change:

  • Location information is now expected to be an array with three elements instead of a string to allow for more flexibility in formatting.

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

coveralls commented Dec 2, 2025

Pull Request Test Coverage Report for Build 19902084837

Details

  • 14 of 14 (100.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.03%) to 97.862%

Totals Coverage Status
Change from base Build 19869004832: 0.03%
Covered Lines: 961
Relevant Lines: 982

💛 - Coveralls

@mitlib mitlib temporarily deployed to timdex-ui-pi-use-246-ho-6sywka December 2, 2025 16:53 Inactive
Why are these changes being introduced:

* This information is useful to users to understand if an item is
  available for checkout or needs to be requested.

Relevant ticket(s):

* https://mitlibraries.atlassian.net/browse/USE-246

How does this address that need:

* Creates a helper method to format availability information
* Updates the result partial to display availability information

Document any side effects to this change:

* Location information is now expected to be an array with three elements
  instead of a string to allow for more flexibility in formatting.
@JPrevost JPrevost temporarily deployed to timdex-ui-pi-use-246-ho-6sywka December 2, 2025 18:18 Inactive
# Expects an array with three elements: [library name, location name, call number]
def location(loc)
"<strong>#{loc[0]}</strong> #{loc[1]} (#{loc[2]})"
end
Copy link
Contributor

Choose a reason for hiding this comment

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

From my end I think I have everything I need: an element around the library title to style as needed, and an icon element with a unique class to change colors if desired.

@JPrevost JPrevost temporarily deployed to timdex-ui-pi-use-246-ho-6sywka December 2, 2025 20:19 Inactive
@matt-bernhardt matt-bernhardt self-assigned this Dec 2, 2025
Copy link
Member

@matt-bernhardt matt-bernhardt left a comment

Choose a reason for hiding this comment

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

I've got two comments, one is a concern about rendering the availability statement inside the links.each loop that feels like it might not be what we want, and the other is more of a vague disquiet about the format of data being returned by the NormalizePrimo model.

I'm willing to approve this as-is if there's something about the links and availability information that prevents there from being any availability statement for a record with multiple links - I just don't know if this condition ever arises, because I'm not sure the code here handles that the way we're wanting.

My other concern is more of a general statement - if hearing it doesn't trip any concerns for you, it won't be a blocker for my approval.

<% if result[:links].present? %>
<% result[:links].each do |link| %>
<%= link_to link['kind'].titleize, link['url'], class: 'button' %>
<% if result[:availability].present? %>
Copy link
Member

Choose a reason for hiding this comment

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

This may be a requested change, but I'm not 100% sure.

How likely is it that records have multiple :links entries? It feels a bit awkward, here, to be calling the availability() helper for each link (inside the .each loop, rather than after it) when it doesn't seem like the content will be changing for each one. I'm not sure what constraints exist in Primo, though, so maybe this condition will never arise? The one search I've done looking for results with multiple links had availability information for records with a single location - which isn't a great sample size, but I'm not sure how long I want to fish for the exact condition in our records.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ha, great catch. I'm not positive if this is an actual problem but it definitely feels wrong.

We only ever want this showing up once, so popping it in a loop makes no sense even if it happens to work.

I intend to change this.


loc = @record['delivery']['bestlocation']
["#{loc['mainLocation']} #{loc['subLocation']}", loc['callNumber']]
[loc['mainLocation'], loc['subLocation'], loc['callNumber']]
Copy link
Member

Choose a reason for hiding this comment

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

I'm slightly worried that this approach is a bit more fragile, by returning a list of entries that aren't all the same, than it would be if it was returned in key-value format. Doing it this way requires the helper method to deal with loc[0] instead of loc[:mainLocation], which feels a bit more robust.

The concern isn't enough for me to ask for a change, and the prior state of this element was also list, so it isn't a regression - but I'm concerned enough to mention it here in case we're all uneasy. From a quick review of the normalizer model, it's pretty thorough in being object-like for differentiated values, rather than list-like, but there may be cases I'm missing (or this may have been hashed out already and I'm late to the party).

I'd be more concerned if there was any conditional logic in this method where these three values might not all be populated for some reason - so the indexing numbers are at least stable.

Copy link
Member Author

Choose a reason for hiding this comment

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

Noted. I think this is technically fine in terms of functionality based on what data seems to come back from the API, but I agree being more explicit in the normalization would be easier to reason with and thus preferred.

i.e. I think this is stable but unclear but we can likely make it stable and clear.

I'll take a closer look and will likely make a change here.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, location is a common field in which both TIMDEX and Primo need to return the same data structure for us to eventually collapse to a single view. I'll move some of the Helper logic into the Primo normalizer model so we are returning a string instead of an array to better match the current TIMDEX normalizer.

We should move this logic to `holdings` as TIMDEX and Primo are currently normalizing different types
of information to a single field. TIMDEX has both `locations` and `holdings` information available whereas Primo only has `locations`. The information in TIMDEX `holdings` aligns well with what Primo `locations` is doing for us here.

Since we are not using TIMDEX locations or holdings in search results that use the normalizer, I have opted to resolve that under a separate ticket rather than fixing as part of this work. The data structure I am using here for Primo locations should align well with data available in TIMDEX holdings when we move both to USE normalized holdings.
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.

6 participants