-
Notifications
You must be signed in to change notification settings - Fork 0
SCC-5490: Update item location filter #772
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
base: main
Are you sure you want to change the base?
Changes from 4 commits
c693721
1624b80
d591501
989f639
2e07ad1
8e4af59
db7a9c0
b492fdc
32a3f55
9c6c6c7
3cd543a
5c30d62
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| [{ "value": "ma", "label": "Stephen A. Schwarzman Building (SASB)","nickname": "SASB" }, { "value": "pa", "label": "The New York Public Library for the Performing Arts (LPA)","nickname": "LPA" },{ "value": "sc", "label": "Schomburg Center for Research in Black Culture","nickname": "Schomburg" },{ "value": "rc", "label": "Offsite - request in advance"},{ "value": "bu", "label": "Stavros Niarchos Foundation Library (SNFL)", "nickname": "SNFL" }] | ||
| [{ "value": "ma", "label": "Stephen A. Schwarzman Building (SASB)", "shortLabel": "Stephen A. Schwarzman Building", "nickname": "SASB" }, { "value": "pa", "shortLabel": "The New York Public Library for the Performing Arts", "label": "The New York Public Library for the Performing Arts (LPA)","nickname": "LPA" },{ "value": "sc", "label": "Schomburg Center for Research in Black Culture", "shortLabel": "Schomburg Center for Research in Black Culture", "nickname": "Schomburg" },{ "value": "rc", "label": "Offsite - request in advance", "shortLabel": "Offsite"},{ "value": "bu", "label": "Stavros Niarchos Foundation Library (SNFL)", "shortLabel": "Stavros Niarchos Foundation Library", "nickname": "SNFL" }] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,7 +28,19 @@ const Item = require('./models/Item.js') | |
| const RESOURCES_INDEX = process.env.RESOURCES_INDEX | ||
|
|
||
| const ITEM_FILTER_AGGREGATIONS = { | ||
| item_location: { nested: { path: 'items' }, aggs: { _nested: { terms: { size: 100, field: 'items.holdingLocation_packed' } } } }, | ||
| item_location: { | ||
| nested: { path: 'items' }, | ||
| aggs: { | ||
| _nested: { | ||
| terms: { | ||
| size: 100, | ||
| script: { | ||
| source: "def locs = doc['items.holdingLocation.id']; if (locs.size() == 0) return null; def loc = locs.value; int colonIdx = loc.indexOf(':'); if (colonIdx == -1) return null; def locId = loc.substring(colonIdx + 1); if (locId.length() < 2) return null; def parentLoc = locId.substring(0, 2); if (['ma', 'pa', 'sc', 'rc', 'bu'].contains(parentLoc)) { return parentLoc; } return null;" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A few questions about this script!
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Moved out to |
||
| } | ||
| } | ||
| } | ||
| } | ||
| }, | ||
| item_status: { nested: { path: 'items' }, aggs: { _nested: { terms: { size: 100, field: 'items.status_packed' } } } }, | ||
| item_format: { nested: { path: 'items' }, aggs: { _nested: { terms: { size: 100, field: 'items.formatLiteral' } } } } | ||
| } | ||
|
|
@@ -212,6 +224,7 @@ module.exports = function (app, _private = null) { | |
| }).then((resp) => { | ||
| const hitsAndItemAggregations = resp.hits.hits[0]._source | ||
| hitsAndItemAggregations.itemAggregations = resp.aggregations | ||
|
|
||
| return ResourceSerializer.serialize(hitsAndItemAggregations, Object.assign(opts, { root: true })) | ||
| }) | ||
| }) | ||
|
|
@@ -488,8 +501,13 @@ module.exports = function (app, _private = null) { | |
| }, | ||
| location: (locations) => { | ||
| return { | ||
| terms: { | ||
| 'items.holdingLocation.id': locations | ||
| script: { | ||
| script: { | ||
| source: "def locs = doc['items.holdingLocation.id']; if (locs.size() == 0) return false; def loc = locs.value; int colonIdx = loc.indexOf(':'); if (colonIdx == -1) return false; def locId = loc.substring(colonIdx + 1); if (locId.length() < 2) return false; def parentLoc = locId.substring(0, 2); return ['ma', 'pa', 'sc', 'rc', 'bu'].contains(parentLoc) && params.locations.contains(parentLoc);", | ||
| params: { | ||
| locations | ||
| } | ||
| } | ||
| } | ||
| } | ||
| }, | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since
buildingLocationis calculated fromholdingLocation, partner items will continue to return nothing for both. This case is already accounted for on the frontend