From f5be809b4792361c7a62a5b11451c9385479979d Mon Sep 17 00:00:00 2001 From: Matias Bordese Date: Thu, 29 Aug 2024 08:56:03 -0300 Subject: [PATCH] Improve schedule filters before generating user calendar export (#4950) Avoid checking all schedules in an organization when filtering user events during export. This should help with some slow requests we are noticing. --- engine/apps/public_api/views/users.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/engine/apps/public_api/views/users.py b/engine/apps/public_api/views/users.py index 930d1c85ca..524b5ee008 100644 --- a/engine/apps/public_api/views/users.py +++ b/engine/apps/public_api/views/users.py @@ -84,6 +84,8 @@ def get_object(self): permission_classes=(IsAuthenticated,), ) def schedule_export(self, request, pk): - schedules = OnCallSchedule.objects.filter(organization=self.request.auth.organization) + schedules = OnCallSchedule.objects.filter(organization=self.request.auth.organization).related_to_user( + self.request.user + ) export = user_ical_export(self.request.user, schedules) return Response(export)