membershipworks: Fix bad grouping in EventExt.summarize using subquery
This commit is contained in:
parent
bfa04be2d9
commit
df621988f6
@ -433,7 +433,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=Count("meeting_times", filter=F("occurred")),
|
meeting_times__count=Count("meeting_times__count", 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")),
|
||||||
@ -444,7 +444,13 @@ class EventExtQuerySet(models.QuerySet["EventExt"]):
|
|||||||
class EventExtManager(models.Manager["EventExt"]):
|
class EventExtManager(models.Manager["EventExt"]):
|
||||||
def get_queryset(self) -> models.QuerySet["EventExt"]:
|
def get_queryset(self) -> models.QuerySet["EventExt"]:
|
||||||
return EventExtQuerySet(self.model, using=self._db).annotate(
|
return EventExtQuerySet(self.model, using=self._db).annotate(
|
||||||
Count("meeting_times"),
|
meeting_times__count=Subquery(
|
||||||
|
EventMeetingTime.objects.filter(event=OuterRef("pk"))
|
||||||
|
.values("event__pk")
|
||||||
|
.annotate(d=Count("pk"))
|
||||||
|
.values("d")[:1],
|
||||||
|
output_field=models.IntegerField(),
|
||||||
|
),
|
||||||
duration=Subquery(
|
duration=Subquery(
|
||||||
EventMeetingTime.objects.filter(event=OuterRef("pk"))
|
EventMeetingTime.objects.filter(event=OuterRef("pk"))
|
||||||
.values("event__pk")
|
.values("event__pk")
|
||||||
|
Loading…
Reference in New Issue
Block a user