Skip to content

Commit

Permalink
update this with class name
Browse files Browse the repository at this point in the history
  • Loading branch information
charmingduchess committed Dec 20, 2024
1 parent ef7b80f commit 7877170
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions lib/delivery-locations-resolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class DeliveryLocationsResolver {
}

static requestableBasedOnHoldingLocation (item) {
const locationCode = this.extractLocationCode(item)
const locationCode = DeliveryLocationsResolver.extractLocationCode(item)

if (!DeliveryLocationsResolver.nyplCoreLocation(locationCode)) {
logger.warn(`DeliveryLocationsResolver: Unrecognized holdingLocation for ${item.uri}: ${locationCode}`)
Expand Down Expand Up @@ -166,7 +166,7 @@ class DeliveryLocationsResolver {
return {
id: `loc:${location.code}`,
label: location.label,
sortPosition: this.sortPosition(location)
sortPosition: DeliveryLocationsResolver.sortPosition(location)
}
})
// Either way, sort deliveryLocation entries by name:
Expand All @@ -191,14 +191,14 @@ class DeliveryLocationsResolver {
}

static attachRecapDeliveryInfo (item) {
const info = this.getRecapDeliveryInfo(item)
const info = DeliveryLocationsResolver.getRecapDeliveryInfo(item)
item.eddRequestable = info.eddRequestable
item.deliveryLocation = info.deliveryLocation
return item
}

static attachOnsiteDeliveryInfo (item) {
const info = this.getOnsiteDeliveryInfo(item)
const info = DeliveryLocationsResolver.getOnsiteDeliveryInfo(item)
item.eddRequestable = info.eddRequestable
item.deliveryLocation = info.deliveryLocation
return item
Expand All @@ -212,15 +212,15 @@ class DeliveryLocationsResolver {
const hasRecapCustomerCode = item.recapCustomerCode && item.recapCustomerCode[0]
const nyplItem = isItemNyplOwned(item)
if (!hasRecapCustomerCode) {
const requestableBasedOnHoldingLocation = nyplItem ? this.requestableBasedOnHoldingLocation(item) : true
const requestableBasedOnHoldingLocation = nyplItem ? DeliveryLocationsResolver.requestableBasedOnHoldingLocation(item) : true
// the length of the list of delivery locations is checked later to determine physical requestability
// In case of an offsite item with no recap customer code, we want this to be based on holding location
// so we put a placeholder '' in case it is requestable based on holding location
deliveryLocation = requestableBasedOnHoldingLocation ? [''] : []
eddRequestable = requestableBasedOnHoldingLocation
} else if (!nyplItem || this.requestableBasedOnHoldingLocation(item)) {
deliveryLocation = this.deliveryLocationsByRecapCustomerCode(item.recapCustomerCode[0])
eddRequestable = this.__eddRequestableByCustomerCode(item.recapCustomerCode[0])
} else if (!nyplItem || DeliveryLocationsResolver.requestableBasedOnHoldingLocation(item)) {
deliveryLocation = DeliveryLocationsResolver.deliveryLocationsByRecapCustomerCode(item.recapCustomerCode[0])
eddRequestable = DeliveryLocationsResolver.__eddRequestableByCustomerCode(item.recapCustomerCode[0])
} else {
deliveryLocation = []
eddRequestable = false
Expand All @@ -233,7 +233,7 @@ class DeliveryLocationsResolver {
eddRequestable: false,
deliveryLocation: []
}
const holdingLocationCode = this.extractLocationCode(item)
const holdingLocationCode = DeliveryLocationsResolver.extractLocationCode(item)
const sierraData = DeliveryLocationsResolver.nyplCoreLocation(holdingLocationCode)
if (!sierraData) {
// This case is mainly to satisfy a test which wants eddRequestable = false
Expand All @@ -243,15 +243,15 @@ class DeliveryLocationsResolver {
}
// if nypl core says it's unrequestable, it can still be eddRequestable,
// but its definitely not phys requestable.
deliveryInfo.eddRequestable = this.eddRequestableByOnSiteCriteria(item)
if (!this.requestableBasedOnHoldingLocation(item)) {
deliveryInfo.eddRequestable = DeliveryLocationsResolver.eddRequestableByOnSiteCriteria(item)
if (!DeliveryLocationsResolver.requestableBasedOnHoldingLocation(item)) {
return deliveryInfo
}
// if nypl-core reports that a holding location's delivery locations
// should be found by M2 code, but only if the item has an M2 customer code
const deliverableToResolution = sierraData.deliverableToResolution
if (deliverableToResolution === 'm2-customer-code' && item.m2CustomerCode && item.m2CustomerCode[0]) {
deliveryInfo.deliveryLocation = this.deliveryLocationsByM2CustomerCode(item.m2CustomerCode[0])
deliveryInfo.deliveryLocation = DeliveryLocationsResolver.deliveryLocationsByM2CustomerCode(item.m2CustomerCode[0])
}
// if no value, default to sierra location lookup
if (!deliverableToResolution) {
Expand All @@ -275,15 +275,15 @@ class DeliveryLocationsResolver {
}

/**
* Given an array of items (ES hits), returns the same items with `eddRequestable` & `deliveryLocations`. We verify all recap customer because our indexed data may be stale.
* Given an array of items (ES hits), returns the same items with `eddRequestable` & `deliveryLocations`. We verify all recap customer because our indexed data may be stale.
*
* @return Promise<Array<items>> A Promise that resolves and array of items, modified to include `eddRequestable` & `deliveryLocations`
*/
static attachDeliveryLocationsAndEddRequestability (items, scholarRoom) {
// Extract ReCAP barcodes from items:
const recapBarcodes = this.extractRecapBarcodes(items)
const recapBarcodes = DeliveryLocationsResolver.extractRecapBarcodes(items)
// Get a map from barcodes to ReCAP customercodes:
return this.__recapCustomerCodesByBarcodes(recapBarcodes)
return DeliveryLocationsResolver.__recapCustomerCodesByBarcodes(recapBarcodes)
.then((barcodeToRecapCustomerCode) => {
// Now map over items to affix deliveryLocations:
return items.map((item) => {
Expand All @@ -292,15 +292,15 @@ class DeliveryLocationsResolver {
item.recapCustomerCode = [barcodeToRecapCustomerCode[barcode]]
// If recap has a customer code for this barcode, map it by recap cust code:
if (item.recapCustomerCode[0]) {
item = this.attachRecapDeliveryInfo(item)
item = DeliveryLocationsResolver.attachRecapDeliveryInfo(item)
// Otherwise, it's an onsite item
} else {
item = this.attachOnsiteDeliveryInfo(item)
item = DeliveryLocationsResolver.attachOnsiteDeliveryInfo(item)
}
// Establish default for Electronic Document Delivery flag:
item.eddRequestable = !!item.eddRequestable
const filteredDeliveryLocationsWithScholarRoom = this.filterLocations(item.deliveryLocation, scholarRoom)
item.deliveryLocation = this.formatLocations(filteredDeliveryLocationsWithScholarRoom)
const filteredDeliveryLocationsWithScholarRoom = DeliveryLocationsResolver.filterLocations(item.deliveryLocation, scholarRoom)
item.deliveryLocation = DeliveryLocationsResolver.formatLocations(filteredDeliveryLocationsWithScholarRoom)
return item
})
})
Expand Down

0 comments on commit 7877170

Please sign in to comment.