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

UIQM-724 do not group together subfields during linking #750

Merged
merged 4 commits into from
Oct 31, 2024
Merged

Conversation

BogdanDenis
Copy link
Contributor

@BogdanDenis BogdanDenis commented Oct 29, 2024

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 class MarcFieldContent.
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

Copy link

github-actions bot commented Oct 29, 2024

Jest Unit Test Results

  1 files  ± 0   48 suites  +1   3m 10s ⏱️ +26s
485 tests +10  485 ✅ +10  0 💤 ±0  0 ❌ ±0 
488 runs  +10  488 ✅ +10  0 💤 ±0  0 ❌ ±0 

Results for commit 6a56448. ± Comparison against base commit fc3424b.

♻️ This comment has been updated with latest results.

@BogdanDenis BogdanDenis requested review from Dmytro-Melnyshyn and a team October 29, 2024 16:35
@BogdanDenis BogdanDenis marked this pull request as ready for review October 29, 2024 16:35

const isSubfieldControlled = (subfieldLetter) => {
return linkingRule.authoritySubfields.includes(subfieldLetter)
|| linkingRule.subfieldModifications.find(mod => mod.target === subfieldLetter);
Copy link
Contributor

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.

Copy link
Contributor Author

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
image

Copy link
Contributor

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.

Copy link
Contributor Author

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: [],
Copy link
Contributor

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();
Copy link
Contributor

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.

Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
C Reliability Rating on New Code (required ≥ A)

See analysis details on SonarCloud

Catch issues before they fail your Quality Gate with our IDE extension SonarLint

@BogdanDenis BogdanDenis merged commit ba58778 into master Oct 31, 2024
14 of 15 checks passed
@BogdanDenis BogdanDenis deleted the UIQM-724 branch October 31, 2024 11:48
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.

3 participants