membershipworks: Change name for EventExt.meetings to avoid extra queries

This commit is contained in:
Adam Goldsmith 2024-01-29 14:04:35 -05:00
parent dafd8cc620
commit 29e87c4468
2 changed files with 5 additions and 5 deletions

View File

@ -438,7 +438,7 @@ class EventExtQuerySet(models.QuerySet["EventExt"]):
return method( return method(
count__sum=Sum("count", filter=F("occurred")), count__sum=Sum("count", filter=F("occurred")),
instructor__count=Count("instructor", distinct=True, 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")), duration__sum=Sum("duration", filter=F("occurred")),
person_hours__sum=Sum("person_hours", filter=F("occurred")), person_hours__sum=Sum("person_hours", filter=F("occurred")),
event_count=Count("eid", filter=F("occurred")), event_count=Count("eid", filter=F("occurred")),
@ -452,7 +452,7 @@ class EventExtManager(models.Manager["EventExt"]):
super() super()
.get_queryset() .get_queryset()
.annotate( .annotate(
meeting_times__count=Subquery( meetings=Subquery(
EventMeetingTime.objects.filter(event=OuterRef("pk")) EventMeetingTime.objects.filter(event=OuterRef("pk"))
.values("event__pk") .values("event__pk")
.annotate(d=Count("pk")) .annotate(d=Count("pk"))

View File

@ -133,7 +133,7 @@ class EventTable(tables.Table):
start = tables.DateColumn("N d, Y") start = tables.DateColumn("N d, Y")
duration = DurationColumn() duration = DurationColumn()
person_hours = DurationColumn() person_hours = DurationColumn()
meeting_times__count = tables.Column("Meetings") meetings = tables.Column()
class Meta: class Meta:
model = EventExt model = EventExt
@ -145,7 +145,7 @@ class EventTable(tables.Table):
"category", "category",
"count", "count",
"cap", "cap",
"meeting_times__count", "meetings",
"duration", "duration",
"person_hours", "person_hours",
) )
@ -161,7 +161,7 @@ class EventSummaryTable(tables.Table):
canceled_event_count = tables.Column("Canceled Events") canceled_event_count = tables.Column("Canceled Events")
count__sum = tables.Column("Tickets") count__sum = tables.Column("Tickets")
instructor__count = tables.Column("Unique Instructors") instructor__count = tables.Column("Unique Instructors")
meeting_times__count__sum = tables.Column("Meetings") meetings__sum = tables.Column("Meetings")
duration__sum = DurationColumn("Class Hours") duration__sum = DurationColumn("Class Hours")
person_hours__sum = DurationColumn("Person Hours") person_hours__sum = DurationColumn("Person Hours")