Skip to content

Commit

Permalink
Merge pull request #105 from NYPL/SCC-4455-multiple-910a
Browse files Browse the repository at this point in the history
[SCC-4455] Support multiple 910|a fields
  • Loading branch information
yossariano authored Jan 22, 2025
2 parents c4affcd + 6b6f1c9 commit 20e3e55
Show file tree
Hide file tree
Showing 4 changed files with 538 additions and 11 deletions.
20 changes: 10 additions & 10 deletions lib/sierra-models/bib.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ class SierraBib extends SierraBase {
// https://github.com/NYPL/nypl-core/blob/master/vocabularies/csv/locations.csv#L2265
const hasOtfLocation = this.locations && this.locations[0] && this.locations[0].code === 'os'

// Having 910 $a === 'RLOTF' is also a solid indicator introduced in OTF
// Having 910 $a contain 'RLOTF' is also a solid indicator introduced in OTF
// record creation Oct 2021 https://github.com/NYPL/recap-hold-request-consumer/pull/33
const hasOtf910 = this._varField910() === 'RLOTF'
const hasOtf910 = this._varField910a().includes('RLOTF')

return hasOtfLocation || hasOtf910
}
Expand Down Expand Up @@ -70,10 +70,10 @@ class SierraBib extends SierraBase {
}

// Check 910 $a for RL or BL:
const researchBranchFlag = this._varField910()
if (researchBranchFlag) {
const isResearch = ['RL', 'RLOTF'].includes(researchBranchFlag)
return { isResearch, rationale: `910 $a is ${researchBranchFlag}` }
const researchBranchFlags = this._varField910a()
if (researchBranchFlags.length !== 0) {
const isResearch = researchBranchFlags.includes('RL') || researchBranchFlags.includes('RLOTF')
return { isResearch, rationale: `910 $a is ${researchBranchFlags}` }
}

// If bib has Research locations, it's Research
Expand Down Expand Up @@ -103,14 +103,14 @@ class SierraBib extends SierraBase {
}

/**
* Get the value in 910 $a if one exists.
* Get the values in 910 $a.
*
* This value typically has RL for Research bibs, BL for Branch bibs, or
* These values typically are RL for Research bibs, BL for Branch bibs, or
* RLOTF for OTF (Research) bibs
*/
_varField910 () {
_varField910a () {
const varField = this.varField('910', ['a'])
return Array.isArray(varField) ? varField[0]?.value : null
return Array.isArray(varField) ? varField.map(field => field.value) : []
}

/**
Expand Down
Loading

0 comments on commit 20e3e55

Please sign in to comment.