Skip to content
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

Merged
merged 9 commits into from
Sep 10, 2024
Merged

Scc 4167/all items #401

merged 9 commits into from
Sep 10, 2024

Conversation

charmingduchess
Copy link
Contributor

@charmingduchess charmingduchess commented Sep 9, 2024

preliminary PR for all_items. Currently includes:

  • params parsing to include all_items and separate ES body construction from other findByUri queries
    • body also removes the exclusion of *_sort properties so we can...
  • sorts items on enumerationChronology_sort
  • tests!
    • testing that params are parsed and overrides happen
    • ensure that sorting happens properly (see comment in the code about this)
    • ensure that electronic item shenanigans happen properly

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.

@charmingduchess charmingduchess marked this pull request as draft September 9, 2024 16:21
@@ -19,8 +18,11 @@ class ResponseMassager {
*
* Also copies ".total" properties into convenient places for serialization.
*/
processInnerHitsProperties (response) {
processInnerHitsProperties (response, allItemsBibQuery) {
Copy link
Contributor Author

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.

Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Member

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.

Copy link
Contributor Author

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.

@charmingduchess charmingduchess marked this pull request as ready for review September 10, 2024 14:55
Copy link
Member

@nonword nonword left a 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!

@@ -19,8 +18,11 @@ class ResponseMassager {
*
* Also copies ".total" properties into convenient places for serialization.
*/
processInnerHitsProperties (response) {
processInnerHitsProperties (response, allItemsBibQuery) {
Copy link
Member

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.

Copy link
Member

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.

@charmingduchess charmingduchess merged commit 63740f9 into main Sep 10, 2024
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants