Skip to content

Commit

Permalink
Merge branch 'qa2' into qa2-refactor-searchathon-fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
nonword committed Oct 18, 2024
2 parents 635c3d1 + f1ebec6 commit 48772b2
Show file tree
Hide file tree
Showing 66 changed files with 403,148 additions and 23 deletions.
2 changes: 1 addition & 1 deletion config/qa.env
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Greg built self-hosted qa domain:
ENCRYPTED_ELASTICSEARCH_URI=AQECAHh7ea2tyZ6phZgT4B9BDKwguhlFtRC6hgt+7HbmeFsrsgAAAJYwgZMGCSqGSIb3DQEHBqCBhTCBggIBADB9BgkqhkiG9w0BBwEwHgYJYIZIAWUDBAEuMBEEDMIkDoQ9C/cCDCAq1wIBEIBQ+L3OgUGeOW9rs1CWkhpBjwM4LbbVRFIWedqew4UXIeSNMJ8cO9SNe4YGCUIoKwCDYt7W7ip3VtDRRRMVvz6QJw+Eg8ugTMVs2pbNFGNvaAQ=
ENCRYPTED_RESOURCES_INDEX=AQECAHh7ea2tyZ6phZgT4B9BDKwguhlFtRC6hgt+7HbmeFsrsgAAAHIwcAYJKoZIhvcNAQcGoGMwYQIBADBcBgkqhkiG9w0BBwEwHgYJYIZIAWUDBAEuMBEEDKS+EEsLB1iiqsC/YwIBEIAvBJpaq8IQcbTPYdgywjBfeUcMaWENUOftxSiVsdG01Rh56dDv/ITrYTHAqqXK/DU=
ENCRYPTED_RESOURCES_INDEX=AQECAHh7ea2tyZ6phZgT4B9BDKwguhlFtRC6hgt+7HbmeFsrsgAAAHIwcAYJKoZIhvcNAQcGoGMwYQIBADBcBgkqhkiG9w0BBwEwHgYJYIZIAWUDBAEuMBEEDGjIeRRI3cN5LwfcmgIBEIAvkB3K4sxagpqspNa3b3BnJQgbw6Ic0jDhuXzk8gmrCiGNMR90YjTZmyLj9aVUN3M=
ENCRYPTED_ELASTICSEARCH_API_KEY=AQECAHh7ea2tyZ6phZgT4B9BDKwguhlFtRC6hgt+7HbmeFsrsgAAAJ4wgZsGCSqGSIb3DQEHBqCBjTCBigIBADCBhAYJKoZIhvcNAQcBMB4GCWCGSAFlAwQBLjARBAx+kryf2KUmGdBYD9sCARCAV3ygz3eXIdq8JX/wpG9JRWlTNMRcpNE1qT0zNlN4t+ZvXEoedLQa/3p1YjgHw06GIAdA9xtkMV4eH9a1K8uCvjP8XxxNKekcMj59TlResnu9QF3r7pGXuQ==

ENCRYPTED_SCSB_URL=AQECAHh7ea2tyZ6phZgT4B9BDKwguhlFtRC6hgt+7HbmeFsrsgAAAH8wfQYJKoZIhvcNAQcGoHAwbgIBADBpBgkqhkiG9w0BBwEwHgYJYIZIAWUDBAEuMBEEDBKllElmWYLxGOGopQIBEIA8JJyKde/8m8iCJGKR5D8HoTJhXHeyvw9eIDeuUNKiXLfJwoVz+PDAZSxkCQtM9O91zGhXbe3l6Bk1RlYJ
Expand Down
7 changes: 5 additions & 2 deletions lib/jsonld_serializers.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ class JsonLdItemSerializer extends JsonLdSerializer {
}
})

// If updatedAt (int) found, add updatedAtDate (Date string)
if (stmts.updatedAt && /^\d+$/.test(stmts.updatedAt)) {
stmts.updatedAtDate = (new Date(stmts.updatedAt)).toISOString()
}

return stmts
}

Expand Down Expand Up @@ -228,8 +233,6 @@ class ResourceSerializer extends JsonLdItemSerializer {
})
}

stmts.suppressed = this.body.suppressed === true

if (this.body.items) {
stmts.items = this.body.items
// Amend items to include source identifier (e.g. urn:SierraNypl:1234, urn:RecapCul:4567)
Expand Down
20 changes: 18 additions & 2 deletions lib/resources.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,17 @@ const SORT_FIELDS = {
}

// The following fields can be excluded from ES responses because we don't pass them to client:
const EXCLUDE_FIELDS = ['uris', '*_packed', '*_sort', 'items.*_packed', 'contentsTitle']
const EXCLUDE_FIELDS = [
'uris',
'*_packed',
'*_sort',
'items.*_packed',
'contentsTitle',
'suppressed',
// Hide contributor and creator transformed fields:
'*WithoutDates',
'*Normalized'
]

// Configure controller-wide parameter parsing:
const parseSearchParams = function (params) {
Expand Down Expand Up @@ -111,6 +121,12 @@ module.exports = function (app, _private = null) {
include_item_aggregations: { type: 'boolean', default: true }
})

// Validate uri:
const { id, nyplSource } = NyplSourceMapper.instance().splitIdentifier(params.uri)
if (!id || !nyplSource) {
throw new errors.InvalidParameterError(`Invalid bnum: ${params.uri}`)
}

// If we need to return itemAggregations or filter on item_status,
// then we need to pre-retrieve SCSB item statuses to incorporate them into
// aggregations and filters.
Expand Down Expand Up @@ -211,7 +227,7 @@ module.exports = function (app, _private = null) {
.then((resp) => {
// need to check that the query actually found an entry
if (!resp.data) {
throw new errors.NotFoundError('Record not found')
throw new errors.NotFoundError(`Record not found: bibs/${nyplSource}/${id}`)
} else {
return resp.data
}
Expand Down
Loading

0 comments on commit 48772b2

Please sign in to comment.