Skip to content

Background processing with Celery #2350

Description

@luytena

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.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions