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

Background processing with Celery #2350

Open
luytena opened this issue Jan 6, 2025 · 1 comment
Open

Background processing with Celery #2350

luytena opened this issue Jan 6, 2025 · 1 comment

Comments

@luytena
Copy link
Contributor

luytena commented Jan 6, 2025

Certain tasks in caluma can currently lead to timeouts when performed with large amounts of data. One example is the recalculation of calculated answers when modifying the calc expression of a calculated question:

@receiver(post_save, sender=models.Question)
@disable_raw
@filter_events(lambda instance: instance.type == models.Question.TYPE_CALCULATED_FLOAT)
def update_calc_from_question(sender, instance, created, update_fields, **kwargs):
# TODO optimize: only update answers if calc_expression is updated
# needs to happen during save() or __init__()
for document in models.Document.objects.filter(form__questions=instance):
update_or_create_calc_answer(instance, document)

Tasks such as this (there might be other examples as well) would benefit from moving them into a background task using Celery.

@open-dynaMIX
Copy link
Member

Related to #2339.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants