-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
Add MAX_PAGE_SIZE setting #9107
base: master
Are you sure you want to change the base?
Add MAX_PAGE_SIZE setting #9107
Conversation
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 think this deserve a test case,, but as it is adding/exposing new API surface to the framework, we might need to pass the design decision step first
OK I saw the comment now #6185 (comment) it might be possible in class level but not globally at the moment. |
@auvipy I added tests for system checks, but didn't managed to find and add tests for settings with API requests like in |
we got a PR related to this area #8993. would be helpful if you review and share your views on the PR. |
@auvipy @christophehenry @TheSuperiorStanislav If you don't mind, I can take this up and implement the changes requested |
456a1fe
to
b51141c
Compare
@auvipy @christophehenry Could you please take a look? Sorry for taking that long, btw 🥲 |
def page_size(self) -> int: | ||
"""Get default page size. | ||
|
||
Defaults to `None`, meaning pagination is disabled. | ||
|
||
""" |
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.
There shoud probably be a comment explaining why this i a property to avoid removing it in a future refactor?
Looks good to me. Thank you. |
@auvipy Could you take a look, please? This pr has been here for a while) |
limit_query_param = 'limit' | ||
limit_query_description = _('Number of results to return per page.') | ||
offset_query_param = 'offset' | ||
offset_query_description = _('The initial index from which to return the results.') | ||
max_limit = None |
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.
Can we avoid changing the style here?
max_limit = api_settings.MAX_PAGE_SIZE
Perfer minimal impact footprints for PRs.
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.
It's related to #8993 and #9107 (comment). Without it we can't properly test it, since this setting will be set during init.
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.
Hrm... not sure? If you'd like to take that approach then I'd probably suggest handling #8993 separately, as a precursor to this.
Unclear to me why that'd be different to attributes we use in other cases.
Description
Add a setting for max page size for global pagination. Our team discovered that by default, page size is unlimited which could lead to API abuse and the only way to fix it -> it's to subclass pagination class(which is a working solution, but not convenient). After investigating issues I found related issue and comment.