Skip to content

Commit

Permalink
Execute post submission async tasks after transaction commit
Browse files Browse the repository at this point in the history
Signed-off-by: Kipchirchir Sigei <[email protected]>
  • Loading branch information
KipSigei committed Sep 1, 2023
1 parent e5bdec9 commit cc2e049
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions onadata/apps/logger/models/instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -829,9 +829,19 @@ def post_save_submission(sender, instance=None, created=False, **kwargs):
_update_xform_submission_count_delete(instance)

if ASYNC_POST_SUBMISSION_PROCESSING_ENABLED:
update_xform_submission_count_async.apply_async(args=[instance.pk, created])
save_full_json_async.apply_async(args=[instance.pk, created])
update_project_date_modified_async.apply_async(args=[instance.pk, created])
transaction.on_commit(
lambda: update_xform_submission_count_async.apply_async(
args=[instance.pk, created]
)
)
transaction.on_commit(
lambda: save_full_json_async.apply_async(args=[instance.pk, created])
)
transaction.on_commit(
lambda: update_project_date_modified_async.apply_async(
args=[instance.pk, created]
)
)

else:
update_xform_submission_count(instance.pk, created)
Expand Down

0 comments on commit cc2e049

Please sign in to comment.