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

fix open-data endpoint timeout bug #2435

Merged
merged 5 commits into from
Jun 14, 2023
Merged

Conversation

kelvin-muchiri
Copy link
Contributor

@kelvin-muchiri kelvin-muchiri commented Jun 13, 2023

Changes / Features implemented

Fix the peculiar intermittent bug where after applying pagination on the GET api/v2/open-data/<uuid>/data endpoint, the server timeouts if the number of submissions is one but seems to have no problem if the number of submissions is more than 1

The fix involves ordering the results only when the queryset returns more than 1 result and only calling the pagination class if the result is more than 1

At the moment, it is not known how applying ordering on the queryset causes the execution to get stuck when getting the first item and not the rest of the items

Other enhancements to optimize the queryset was to make use of only() to ensure we only get the field(s) we are accessing and the use of Queryset.__len__ instead of count() to count the number of items

Steps taken to verify this change does what is intended

  • QA

Side effects of implementing this change

The timeout experienced when pagination is applied for endpoint GET api/v2/open-data/<uuid>/data on some occasions should be fixed

Before submitting this PR for review, please make sure you have:

  • Included tests
  • Updated documentation

Closes #2436

there currently exists a peculiar intermittent bug where after ordering the queryset and
the first item is accessed such as instances[0] or by slicing instances[0:1] (as in the
the pagination implementation) the execution freezes and no result is returned.
This causes the server to timeout. The workaround only ensures we order and paginate
the results only when the queryset returns more than 1 item
add test case for count query parameter on endpoint /api/v2/open-data/<uuid>/data
KipSigei
KipSigei previously approved these changes Jun 13, 2023
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.

Server timeouts out on endpoint GET /api/v2/open-data/<uuid>/data?page=1 when only 1 submission is present
2 participants