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

Miscellaneous internal changes #256

Merged
merged 4 commits into from
Mar 2, 2023
Merged

Miscellaneous internal changes #256

merged 4 commits into from
Mar 2, 2023

Conversation

alexdunnjpl
Copy link
Contributor

🗒️ Summary

Preliminary work undertaken as part of #252 which does not actually resolve it (since it has been deprioritized but the work is still useful).

  • Add internal IllegalArgumentException to invalid start and limit setter calls
  • Remove summaryOnly-related internal code and rework Singular/Plural API route behaviour to be more explicit

⚙️ Test Data and/or Report

One of the following should be included here:
See Github Actions tests

♻️ Related Issues

Fixes #255
Related to #252

Copy link
Member

@tloubrieu-jpl tloubrieu-jpl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall I like the simplification of the code, but I would like to make sure the behavior is still what we expect/want.

Thanks Alex

@@ -1149,8 +1149,6 @@ components:
syntax: limit=10

behavior: maximum number of matching results returned, for pagination

note: limit=0 returns just the summary
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll keep that note, although data is still returned with length 0, I would like that we made obvious to the users that limit=0 is the way to get the summary only.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that useful information to provide to the user? "If you request zero data you'll get zero data" seems pointless, and specifying that you'll get just the summary (which is actually the search metadata) seems to indicate that something nonstandard occurs. Your call, though.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alexdunnjpl we wanted a way for the user to get the metadata for a set of results, beyond the pagination limits, without requesting them all. That is useful for a user who would like to know the set of properties which can be requested in this products.

The use case is:

  1. user want to explore the product's of a collection (e.g. 100000s products)
  2. the user needs to know which properties are used to describe these products
  3. the user can apply search criteria on some of the available properties to subset the collection of products (these properties cannot be guessed by the user)

That is for step 2 that we initially defined the summaryOnly keyword, and then we decided to remove this keyword to use limit=0 instead. That being said it sounds like the summary does not provide the description for the full request results beyond pagination limits but only for the current page.

Copy link
Contributor Author

@alexdunnjpl alexdunnjpl Mar 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tloubrieu-jpl if I understand you correctly, it sounds like limit=0 is supposed to behave in a different/non-standard manner, then? Specifically, to provide the union of the set of properties present in each product for the given query? (That's a non-homogeneous collection of property sets, yeah? Otherwise the user could just get it with limit=1 and extract the property set themselves)

It currently doesn't, iirc, so sounds like there's a need to make some kind of fix if that's necessary, but that almost seems like a job for a subroute like products/properties?{someQuery} rather than serving it implicitly in the case of products?{someQuery}&limit=0? This also seems like a potentially-expensive operation in the case of large query results, not that there's any getting around that if it's needed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alexdunnjpl I was unclear, I am not looking for a non standard management of limit=0. I believe what is rather needed to be updated is the way the summary is prepared. For the use case I described above, the summary need to be made from the products matching the query (q, keyword) but ignoring the pagination parameters (start, limit). I will make a more detailed ticket for that, because all the summary properties are not equivalent.

}

this.limit = limit;
this.returnSingularDatum = false;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Somehow the property name is not meaningful to me. A bit too abstract maybe.

Copy link
Contributor Author

@alexdunnjpl alexdunnjpl Feb 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This replaces isSingular (dragged down from RequestAndResponseContext). The meaning is "this URIParameters is being used for an API route which returns a single element (ex. /bundles/{identifier}) rather than a collection of elements (ex. /bundles/{identifier}/products)".

Open to suggestions on this as you're right - it's not great.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alexdunnjpl , What about something like expectSingularResponse ?

Copy link
Contributor Author

@alexdunnjpl alexdunnjpl Mar 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's slightly better, but I'm starting to feel like if it's worth worrying about, it's worth doing properly (see the last bit of the comment in the next thread), so unless you have an objection I think that I should

  • make it an enum type instead of a boolean
  • put an explanatory comment in the enum type so that anyone who wonders/cares what exactly it refers to can jump to the explanation with a minimum of effort

Copy link
Contributor Author

@alexdunnjpl alexdunnjpl Mar 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, how about singletonResultExpected?

Communicates that the expected singularness applies to the result (of the query), and I think that "singleton" makes the connection a little clearer because it either means "a unique instance" or "a set with cardinality 1", both of which are correct in this context.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tloubrieu-jpl tentatively resolved by 90c4fb9 (if you agree with the new naming)

Copy link
Member

@tloubrieu-jpl tloubrieu-jpl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fixed the conflict (that I introduced through an update on main branch).
I ran the integration test and I don't see an impact, before merging that would be good to have a review from @al-niessner.

@tloubrieu-jpl
Copy link
Member

@al-niessner could you review this PR ? Thanks

@alexdunnjpl
Copy link
Contributor Author

@al-niessner @tloubrieu-jpl still a couple of outstanding convos (above) before finalization, FYI

@alexdunnjpl
Copy link
Contributor Author

Squash when merging, with following commit message (we've lost the commit history, but at least we can retain the granular messages):

  • add IllegalArgumentException throws to URIParameters setStart() and setLimit() methods
  • excise summaryOnly-related behaviour
  • rework Singular/Plural status of API routes
    this is more explicit than the previous approach
  • remove illegal character
    presence of emoji breaks branch integration testing

@alexdunnjpl alexdunnjpl merged commit 99d25e1 into main Mar 2, 2023
@alexdunnjpl alexdunnjpl deleted the 255-misc-changes branch March 2, 2023 20:55
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.

Incorporate misc changes loosely-related to #252
5 participants