-
Notifications
You must be signed in to change notification settings - Fork 0
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
Scc 4167/all items #401
Scc 4167/all items #401
Conversation
lib/response_massager.js
Outdated
@@ -19,8 +18,11 @@ class ResponseMassager { | |||
* | |||
* Also copies ".total" properties into convenient places for serialization. | |||
*/ | |||
processInnerHitsProperties (response) { | |||
processInnerHitsProperties (response, allItemsBibQuery) { |
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.
I updated the args here because I didn't see a clearer way to branch the logic. I don't love this update, but let me know if you see any alternatives.
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.
I hear you. I think it's fine on balance. This seems like the right place to sort items. What triggers the sorting is the question. An alternative to adding a "do the sorting" param would be to change the check on line 23 to if (hit._source.items.some((i) => i.enumerationChronology_sort))
since items will only have that property when we've specifically requested it for manual sorting. But what you've done is prob clearer.
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.
I can't leave a comment on the exact line, but around line 34-38 it looks like we can get rid of some code.
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.
You mean the part where we populate hit._source.numItemsTotal
? I believe that's there to ensure that we get an accurate items count even if we have active item filters. When there are active item filters we insert a second inner_hits call without any item filters so that we can use that count for numItemsTotal
. In the all_items
case, there are no item filters by definition, so the allItems
inner_hits won't be triggered.
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.
opted for something in the middle - renamed the param in processInnerHitsProperties
to sound more agnostic to what is triggering it.
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.
Looks good to me!
lib/response_massager.js
Outdated
@@ -19,8 +18,11 @@ class ResponseMassager { | |||
* | |||
* Also copies ".total" properties into convenient places for serialization. | |||
*/ | |||
processInnerHitsProperties (response) { | |||
processInnerHitsProperties (response, allItemsBibQuery) { |
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.
I hear you. I think it's fine on balance. This seems like the right place to sort items. What triggers the sorting is the question. An alternative to adding a "do the sorting" param would be to change the check on line 23 to if (hit._source.items.some((i) => i.enumerationChronology_sort))
since items will only have that property when we've specifically requested it for manual sorting. But what you've done is prob clearer.
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.
You mean the part where we populate hit._source.numItemsTotal
? I believe that's there to ensure that we get an accurate items count even if we have active item filters. When there are active item filters we insert a second inner_hits call without any item filters so that we can use that count for numItemsTotal
. In the all_items
case, there are no item filters by definition, so the allItems
inner_hits won't be triggered.
preliminary PR for all_items. Currently includes:
*_sort
properties so we can...I'd love input on any other tests that should be added for this.
I'm also curious about if there is some stale code we can remove from the
innerHitsProperties
method.