Skip to content

Commit

Permalink
Disable "form_versions" calculation for forms after a configurable limit
Browse files Browse the repository at this point in the history
Disable "form_versions" calculation for forms that have submissions that surpass
the "SUBMISSION_RETRIEVAL_THRESHOLD" setting
  • Loading branch information
DavisRayM committed Dec 16, 2020
1 parent c26e764 commit 506f7e6
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions onadata/libs/serializers/xform_serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@
get_enketo_urls, get_form_url)


SUBMISSION_RETRIEVAL_THRESHOLD = getattr(settings,
"SUBMISSION_RETRIEVAL_THRESHOLD",
10000)


def _create_enketo_urls(request, xform):
"""
Generate enketo urls for a form
Expand Down Expand Up @@ -375,6 +380,8 @@ def get_form_versions(self, obj):

if versions:
return versions
elif obj.num_of_submissions > SUBMISSION_RETRIEVAL_THRESHOLD:
return []

versions = list(
Instance.objects.filter(xform=obj, deleted_at__isnull=True)
Expand Down

0 comments on commit 506f7e6

Please sign in to comment.