-
Notifications
You must be signed in to change notification settings - Fork 3
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
UIQM-724 do not group together subfields during linking #750
Conversation
|
||
const isSubfieldControlled = (subfieldLetter) => { | ||
return linkingRule.authoritySubfields.includes(subfieldLetter) | ||
|| linkingRule.subfieldModifications.find(mod => mod.target === subfieldLetter); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
subfieldModifications
is not always present in linking rules, let's add optional chaining.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Dmytro-Melnyshyn I've checked the response and rules that don't have modifications still have an empty array
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's weird that this field isn't everywhere at bugfest.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Dmytro-Melnyshyn asked Pavlo about it and it's because of a json serializer update, in Ramsons we can expect to always have subfieldModifications
autoLinkingEnabled: true, | ||
}, { | ||
id: 12, | ||
bibField: '650', | ||
authorityField: '150', | ||
authoritySubfields: ['a', 'b', 'g'], | ||
subfieldModifications: [], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's remove it for at least one rule to catch the error in tests, since subfieldModifications
is not present in all rules.
bibField.prevContent = bibField.content; | ||
bibField.content = joinSubfields(updatedBibSubfields); | ||
bibField.content = updatedBibSubfields.join(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if it would be better to avoid pretending to be array methods. This implementation looks cool, but is confusing because it is not an array, but uses join
, which is actually reduce
.
Quality Gate failedFailed conditions See analysis details on SonarCloud Catch issues before they fail your Quality Gate with our IDE extension SonarLint |
Description
Fix issue with grouped subfields during linking. Issue is caused by using
getContentSubfieldValue
which iterates over parsed contents and returns an object with key-value pair where a key is a subfield code, and value is an array of subfield values from that code. Therefore, we're losing the order of subfields.Instead added a new utility
getContentSubfieldValueArr
which returns an array of objects with a single subfield code and value, therefore keeping the original order of subfields, and a new classMarcFieldContent
.This class encapsulates some common logic when working with subfields during linking: getting a subfield value, adding a subfield, removing a subfield, joining subfields etc.
Screenshots
chrome_YHbEAULZVE.mp4
Issues
UIQM-724