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

Paginate data list responses after a configurable threshold #2010

Merged
merged 4 commits into from
Feb 4, 2021

Conversation

DavisRayM
Copy link
Contributor

Changes / Features implemented

  • Paginate responses when requested data is more than the retrieval threshold

Steps taken to verify this change does what is intended

  • Added tests

Side effects of implementing this change

Closes #2008

@DavisRayM DavisRayM changed the title Paginate data list responses after a configurable threshold [WIP] Paginate data list responses after a configurable threshold Feb 4, 2021
ivermac
ivermac previously approved these changes Feb 4, 2021
Copy link
Contributor

@ivermac ivermac 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

@DavisRayM DavisRayM changed the title [WIP] Paginate data list responses after a configurable threshold Paginate data list responses after a configurable threshold Feb 4, 2021
pagination_keys = [self.paginator.page_query_param,
self.paginator.page_size_query_param]
query_param_keys = self.request.query_params
should_paginate = any([k in query_param_keys for k in pagination_keys])

if not should_paginate and not is_public_request:
Copy link
Member

Choose a reason for hiding this comment

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

Does this mean we will not paginate public forms that exceed the threshold?

Copy link
Contributor Author

@DavisRayM DavisRayM Feb 4, 2021

Choose a reason for hiding this comment

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

At the moment yes; didn't think of this while implementing the feature... Any thoughts/reservations with always paginating public requests? Seems a bit painful to calculate the entire count(getting all public XForms and summing the num_of_submissions) of public data that's currently available...

Copy link
Member

Choose a reason for hiding this comment

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

This is for a single form request at a time, not all public forms at the same. Also, we could go with num_of_submissions that is not calculated on the fly, it is a safe estimate in most situations.

Copy link
Member

Choose a reason for hiding this comment

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

I withdraw my statement, I see that is_public_request represents access to the /api/v1/data/public and not to one single form data.

@DavisRayM DavisRayM changed the title Paginate data list responses after a configurable threshold [WIP] Paginate data list responses after a configurable threshold Feb 4, 2021
@DavisRayM DavisRayM changed the title [WIP] Paginate data list responses after a configurable threshold Paginate data list responses after a configurable threshold Feb 4, 2021
@DavisRayM DavisRayM merged commit 8377341 into master Feb 4, 2021
@DavisRayM DavisRayM deleted the 2008-data-list-default-limit branch February 4, 2021 13:31
@DavisRayM DavisRayM mentioned this pull request Feb 23, 2021
1 task
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.

Data ViewSet: Automatically paginate requests after a certain submission threshold
3 participants