ApprovalQueue: use a materialized table #240

Merged
Oleg-Komarov merged 4 commits from approval-queue-fix into main 2024-08-23 15:11:46 +02:00
Showing only changes of commit 9362feb2dd - Show all commits

View File

@ -52,17 +52,21 @@ def _update_approval_queue(
return
if not created:
return
if instance.type not in ApprovalActivity.STATUS_CHANGE_TYPES:
return
activity_count = ApprovalActivity.objects.filter(extension=instance.extension).count()
ApprovalQueue.objects.update_or_create(
extension=instance.extension,
defaults={
'activity_count': activity_count,
'latest_activity': instance,
'sortkey': instance.queue_sortkey,
},
)
if instance.type in ApprovalActivity.STATUS_CHANGE_TYPES:
ApprovalQueue.objects.update_or_create(
extension=instance.extension,
defaults={
'activity_count': activity_count,
'latest_activity': instance,
'sortkey': instance.queue_sortkey,
},
)
else:
if item := ApprovalQueue.objects.filter(extension=instance.extension).first():
item.activity_count = activity_count
item.save(update_fields={'activity_count'})
@receiver(pre_delete, sender=ApprovalActivity)