-
Notifications
You must be signed in to change notification settings - Fork 26
feat: add pagination to search_content()
#449
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
Conversation
| page_number = 1, | ||
| page_size = 500, |
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 figured we don't need to expose these to users, since pagination is kind of an implementation detail here. But retaining them and passing them down might make it easier to test performance under different values.
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.
But retaining them and passing them down might make it easier to test performance under different values
Yeah, that's true. A few thoughts: (1) one should be able to pass these down in ... even if they are not included in the signature explicitly. (2) what do our other functions do? If they expose these explicitly so that it's obvious there are nobs to tune here, I'm fine including them. But also fine to not (so long as someone can pass them in ...)
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.
Our other functions don't expose them to users, and ultimately that's the right choice. I will add a test to ensure they get passed down.
I'll note that passing in page_number will just be the starting page of pagination — pagination will still happen.
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.
Cool, sounds good.
I'll note that passing in page_number will just be the starting page of pagination — pagination will still happen.
I'm not sure if this is the right behavior (but we shouldn't fix that here since that's more about the implementation of page_offset). Could you (1) write an issue for this and (2) it would be good to write this down, in a comment at least, but maybe even in the body of the documentation (since we're not explicitly documenting page_number the obvious place is gone, but that's ok even if it's just in the narrative section of the docs, just so someone confused about this and looking would see 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.
I'm not sure if this is the right behavior (but we shouldn't fix that here since that's more about the implementation of
page_offset). Could you (1) write an issue for this and (2) it would be good to write this down, in a comment at least, but maybe even in the body of the documentation (since we're not explicitly documentingpage_numberthe obvious place is gone, but that's ok even if it's just in the narrative section of the docs, just so someone confused about this and looking would see it).
Yeah, this non-intuitiveness was kinda in there in my reasoning for not wanting to include it as an explicit parameter. I'll do both.
[edit] #450
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 disagree on passing the parameters with .... My opinion is that parameters that go through ... should get passed to exported functions with their own documentation. If the only place they're documented is through the ... documentation for this function, to me that just obfuscates them unnecessarily. If we're going to support people providing pagination-related arguments then let's give them informative names that can pop up in tab-completion, etc.
This is just an opinion and doesn't need to block the PR if others feel strongly about the current approach, however.
Co-authored-by: Jonathan Keane <[email protected]>
jonkeane
left a comment
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.
This is great, thanks for something so targeted. I have one suggested improvement, but if you decide not to do that here, that shouldn't hold up the merge.
| test_that("content search passes all parameters through correctly", { | ||
| without_internet( | ||
| expect_GET( | ||
| search_content( | ||
| client, | ||
| q = "bream", | ||
| include = "owner", | ||
| page_number = 2, | ||
| page_size = 5 | ||
| page_size = 20, | ||
| include = "owner" | ||
| ), | ||
| "https://connect.example/__api__/v1/search/content?q=bream&page_number=2&page_size=5&include=owner" | ||
| "https://connect.example/__api__/v1/search/content?q=bream&page_number=2&page_size=20&include=owner" | ||
| ) |
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 know this is just an edit, but this is a great example of the power of httptest: we can assert our handling of the responses where that's important, but here we just need to know it's constructing the URLs correctly to know that we're doing the right thing. 💯
Co-authored-by: Jonathan Keane <[email protected]>
| page_number = 1, | ||
| page_size = 500, |
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 disagree on passing the parameters with .... My opinion is that parameters that go through ... should get passed to exported functions with their own documentation. If the only place they're documented is through the ... documentation for this function, to me that just obfuscates them unnecessarily. If we're going to support people providing pagination-related arguments then let's give them informative names that can pop up in tab-completion, etc.
This is just an opinion and doesn't need to block the PR if others feel strongly about the current approach, however.
@karawoo Good point. It does have a bad feel to it. The other functions that wrap paginated endpoints don't provide pagination controls, and my original intent for this func was to do the same. Added them back in because we may want to use them to test performance of different Your point makes me feel that including them in [edit] I've captured in #450 that the params should be explicit. |
Intent
Add auto-pagination to
search_content().Fixes #447
Approach
page_offset().Checklist
NEWS.md(referencing the connected issue if necessary)?devtools::document()?