From 29e87c4468d1c27d1d0f755d86b00cef64f5f3cd Mon Sep 17 00:00:00 2001 From: Adam Goldsmith Date: Mon, 29 Jan 2024 14:04:35 -0500 Subject: [PATCH] membershipworks: Change name for EventExt.meetings to avoid extra queries --- membershipworks/models.py | 4 ++-- membershipworks/views.py | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/membershipworks/models.py b/membershipworks/models.py index e529626..f7ca734 100644 --- a/membershipworks/models.py +++ b/membershipworks/models.py @@ -438,7 +438,7 @@ class EventExtQuerySet(models.QuerySet["EventExt"]): return method( count__sum=Sum("count", filter=F("occurred")), instructor__count=Count("instructor", distinct=True, filter=F("occurred")), - meeting_times__count__sum=Sum("meeting_times__count", filter=F("occurred")), + meetings__sum=Sum("meetings", filter=F("occurred")), duration__sum=Sum("duration", filter=F("occurred")), person_hours__sum=Sum("person_hours", filter=F("occurred")), event_count=Count("eid", filter=F("occurred")), @@ -452,7 +452,7 @@ class EventExtManager(models.Manager["EventExt"]): super() .get_queryset() .annotate( - meeting_times__count=Subquery( + meetings=Subquery( EventMeetingTime.objects.filter(event=OuterRef("pk")) .values("event__pk") .annotate(d=Count("pk")) diff --git a/membershipworks/views.py b/membershipworks/views.py index 3086370..eba7198 100644 --- a/membershipworks/views.py +++ b/membershipworks/views.py @@ -133,7 +133,7 @@ class EventTable(tables.Table): start = tables.DateColumn("N d, Y") duration = DurationColumn() person_hours = DurationColumn() - meeting_times__count = tables.Column("Meetings") + meetings = tables.Column() class Meta: model = EventExt @@ -145,7 +145,7 @@ class EventTable(tables.Table): "category", "count", "cap", - "meeting_times__count", + "meetings", "duration", "person_hours", ) @@ -161,7 +161,7 @@ class EventSummaryTable(tables.Table): canceled_event_count = tables.Column("Canceled Events") count__sum = tables.Column("Tickets") instructor__count = tables.Column("Unique Instructors") - meeting_times__count__sum = tables.Column("Meetings") + meetings__sum = tables.Column("Meetings") duration__sum = DurationColumn("Class Hours") person_hours__sum = DurationColumn("Person Hours")