ApprovalQueue: use a materialized table #240
@ -52,9 +52,9 @@ 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()
|
||||
if instance.type in ApprovalActivity.STATUS_CHANGE_TYPES:
|
||||
ApprovalQueue.objects.update_or_create(
|
||||
extension=instance.extension,
|
||||
defaults={
|
||||
@ -63,6 +63,10 @@ def _update_approval_queue(
|
||||
'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)
|
||||
|
Loading…
Reference in New Issue
Block a user