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

Improve XForm.last_submission_time #776

Open
jnm opened this issue Oct 29, 2021 · 0 comments
Open

Improve XForm.last_submission_time #776

jnm opened this issue Oct 29, 2021 · 0 comments

Comments

@jnm
Copy link
Member

jnm commented Oct 29, 2021

XForm.objects.filter(pk=instance.xform_id).update(
num_of_submissions=F('num_of_submissions') + 1,
last_submission_time=instance.date_created,
)

last_submission_time should probably be set to the maximum of whatever's already in the database or instance.date_created, not instance.date_created unconditionally. The F expression for num_of_submissions takes away race conditions there, but for last_submission_time, there's a chance of us overwriting a newer timestamp with an older one.

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

No branches or pull requests

1 participant