Skip to content

Commit

Permalink
update build spec requestable
Browse files Browse the repository at this point in the history
  • Loading branch information
charmingduchess committed Dec 19, 2024
1 parent 307d70b commit 3b3db65
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lib/requestability_resolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ const DeliveryLocationsResolver = require('./delivery-locations-resolver')
const { isItemNyplOwned } = require('./ownership_determination')
const { isInRecap } = require('./util')
const logger = require('./logger')

class RequestabilityResolver {
static fixItemRequestability (elasticSearchResponse) {
elasticSearchResponse.hits.hits
.forEach((hit) => {
const parentBibHasFindingAid = !!hit._source.supplementaryContent?.find((el) => el.label === 'Finding aid')
hit._source.items = hit._source.items.map((item) => {
if (item.electronicLocator) return item
let deliveryInfo
Expand All @@ -28,7 +30,8 @@ class RequestabilityResolver {
item.eddRequestable = !!deliveryInfo.eddRequestable
item.physRequestable = !!(deliveryInfo.deliveryLocation &&
deliveryInfo.deliveryLocation.length)
item.specRequestable = !!item.aeonUrl

item.specRequestable = this.buildSpecRequestable(item, parentBibHasFindingAid)
// items without barcodes should not be requestable
const hasBarcode = (item.identifier || []).some((identifier) => /^(urn|bf):[bB]arcode:\w+/.test(identifier))
if (isItemNyplOwned(item) && !hasBarcode) {
Expand All @@ -42,6 +45,13 @@ class RequestabilityResolver {
})
return elasticSearchResponse
}

static buildSpecRequestable (item, parentBibHasFindingAid) {
const holdingLocation = DeliveryLocationsResolver.extractLocationCode(item)
const nyplCoreLocation = DeliveryLocationsResolver.nyplCoreLocation(holdingLocation)
const isSpecialCollectionsOnlyAccessType = !!nyplCoreLocation?.collectionAccessType
return !!item.aeonUrl || parentBibHasFindingAid || isSpecialCollectionsOnlyAccessType
}
}

module.exports = RequestabilityResolver

0 comments on commit 3b3db65

Please sign in to comment.