Skip to content

Commit

Permalink
Filter only active forms on attachments fix command.
Browse files Browse the repository at this point in the history
  • Loading branch information
ukanga committed Jan 23, 2018
1 parent 6d08eaa commit a72bf25
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,16 @@ def process_attachments(self, user):
"""
Process attachments for submissions where media_all_received is False.
"""
xforms = XForm.objects.filter(user=user, deleted_at__isnull=True)
xforms = XForm.objects.filter(user=user, deleted_at__isnull=True,
downloadable=True)
for xform in queryset_iterator(xforms):
submissions = xform.instances.filter(media_all_received=False)
if submissions.count():
self.stdout.write("%s to process %s submissions" % (
xform, submissions.count()))
to_process = submissions.count()
if to_process:
for submission in queryset_iterator(submissions):
update_attachment_tracking(submission)
not_processed = xform.instances.filter(
media_all_received=False).count()
self.stdout.write("%s to process %s - %s = %s processed" % (
xform, to_process, not_processed,
(to_process - not_processed)))

0 comments on commit a72bf25

Please sign in to comment.