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.
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:
caluma/caluma/caluma_form/signals.py
Lines 104 to 114 in 4ea87d0
Tasks such as this (there might be other examples as well) would benefit from moving them into a background task using Celery.