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 call number field in Primo Normalized XML #3075

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

malkaPre
Copy link

@malkaPre malkaPre commented Jul 9, 2023

Before fix:
Call-number field was taken from '//p:display/p:availlibrary' root in the pnx or '//p:browse/p:callnumber' root in the pnx
and that matched primo pnx format.
In primoVE the call-number field exists in a differnt root '//p:delivery/p:bestlocation/p:callNumber' in the pnx.

After fix:
if call-number is empty it will fetch from '//p:delivery/p:bestlocation/p:callNumber'.

Before fix:
Call-number field was taken from '//p:display/p:availlibrary' root in the pnx or '//p:browse/p:callnumber' root in the pnx
and that matched primo pnx format.
In primoVE the call-number field exists in a differnt root '//p:delivery/p:bestlocation/p:callNumber' in the pnx.

After fix:
if call-number is empty it will fetch from '//p:delivery/p:bestlocation/p:callNumber'.
Before fix:
Call-number field was taken from '//p:display/p:availlibrary' root in the pnx or '//p:browse/p:callnumber' root in the pnx
and that matched primo pnx format.
In primoVE the call-number field exists in a differnt root '//p:delivery/p:bestlocation/p:callNumber' in the pnx.

After fix:
if call-number is empty it will fetch from '//p:delivery/p:bestlocation/p:callNumber'.
@zoe-translates
Copy link
Collaborator

Hello, thank you for your first pull request :)

A few comments -

  • Please update the translator files using Scaffold (Zotero -> "Tools" menu -> Developer -> Translator Editor). When you save using Scaffold, it will update the timestamp in the metadata. Without the timestamp update, update to the code will not be picked up by Zotero.
  • Could you provide an example where it used to fail without the change, which is corrected by the change? Have you tried running the tests in Scaffold? If necessary, please consider adding a test. (More on Scaffold: https://www.zotero.org/support/dev/translators/scaffold)
  • Typically there's no need to merge the upstream changes into your branch. You can just focus on adding commits to your branch and push them, so only the affected file shows up in the commits.

Comment on lines +320 to +321
if (callNumber[i].textContent.search(/\$\$2.+\$/) != -1) {
callArray.push(callNumber[i].textContent.match(/\$\$2\(?(.+?)(?:\s*\))?\$/)[1]);
Copy link
Collaborator

Choose a reason for hiding this comment

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

It's not very clear to me what these two regular expressions try to do together. If you want to test whether a string matches a pattern, and if it does, retrieve a group from the match, you typically only need to call match() once and test its return value. If the string doesn't match, it's null; if it matches, it's an array with captured groups.

Copy link
Member

Choose a reason for hiding this comment

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

Agreed. And if we do want to test whether a regex matches, it's better to use /regex/.test(string) instead of string.search(/regex/) != -1.

Primo 2018.js Outdated Show resolved Hide resolved
Comment on lines +320 to +321
if (callNumber[i].textContent.search(/\$\$2.+\$/) != -1) {
callArray.push(callNumber[i].textContent.match(/\$\$2\(?(.+?)(?:\s*\))?\$/)[1]);
Copy link
Member

Choose a reason for hiding this comment

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

Agreed. And if we do want to test whether a regex matches, it's better to use /regex/.test(string) instead of string.search(/regex/) != -1.

@malkaPre
Copy link
Author

Is there any updates on this?

@AbeJellinek
Copy link
Member

See comments from @zoe-translates and me

@malkaPre
Copy link
Author

@AbeJellinek I checked all the comments - and I did whatever was requested:

  1. Updated the translator files using Scaffold.
  2. Gave an example where it used to fail without the change.
  3. You agreed that the following syntax is okay.
    Update call number field in Primo Normalized XML #3075 (comment)
    image

Am I missing out on something?
If yes, I would like you to explain to me what.

@malkaPre
Copy link
Author

malkaPre commented Apr 4, 2024

The customer is requesting for updates. Can you please review and approve the change being requested

@AbeJellinek
Copy link
Member

  • You reverted the lastUpdated change.
  • I didn’t say that the regex was OK. I said that I agreed with @zoe-translates’ comments about the regex being confusing. It is confusing! And we shouldn’t be using search().
  • You didn’t add a test.

@nilinatan
Copy link

Hi @AbeJellinek @zoe-translates

We would like your help in closing this issue, since we have Primo customers that are waiting for this fix.
@malkaPre is encountering with issues while testing using the Scaffold.

We have already implemented your remarks on the regex.
please help to optimize the process as we do want to commit the change and provide the fix.

please suggest if possible options to help and speed this up.

All the best
Nili Natan
Primo, Product Manager
[email protected]

@AbeJellinek
Copy link
Member

@malkaPre is encountering with issues while testing using the Scaffold.

What are those issues?

We have already implemented your remarks on the regex.

No, you did not. Or if you did, you haven't pushed it.

please help to optimize the process as we do want to commit the change and provide the fix.

What do you mean?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants