Compare commits

..

1 commit

Author SHA1 Message Date
81a0959547 Speed up sql
All checks were successful
/ test (pull_request) Successful in 48s
/ test (push) Successful in 49s
/ deploy (push) Successful in 5m13s
2024-11-21 21:26:16 +01:00
2 changed files with 2 additions and 2 deletions

View file

@ -21,7 +21,7 @@ from tickets.shared_serializers import RelationSerializer
class IssueViewSet(viewsets.ModelViewSet):
serializer_class = IssueSerializer
queryset = IssueThread.objects.all().prefetch_related('state_changes', 'comments', 'emails', 'emails__attachments', 'assignments', 'assignments__assigned_to__username', 'related_items', 'item_relations', 'shipping_vouchers')
queryset = IssueThread.objects.all().prefetch_related('state_changes', 'comments', 'emails', 'emails__attachments', 'assignments', 'assignments__assigned_to__username', 'item_relation_changes', 'shipping_vouchers')
class RelationViewSet(viewsets.ModelViewSet):

View file

@ -68,7 +68,7 @@ class IssueSerializer(BasicIssueSerializer):
last_mail = max([t.timestamp for t in self.emails.all()]) if self.emails.exists() else None
last_assignment = max([t.timestamp for t in self.assignments.all()]) if self.assignments.exists() else None
last_relation = max([t.timestamp for t in self.item_relations.all()]) if self.item_relations.exists() else None
last_relation = max([t.timestamp for t in self.item_relation_changes.all()]) if self.item_relation_changes.exists() else None
args = [x for x in [last_state_change, last_comment, last_mail, last_assignment, last_relation] if
x is not None]
return max(args)