membershipworks: Annotate EventExt.meeting_times__count

This commit is contained in:
Adam Goldsmith 2024-01-17 13:37:14 -05:00
parent 8498d311d5
commit 978024c538
2 changed files with 11 additions and 2 deletions

View File

@ -4,7 +4,15 @@ from datetime import datetime
import django.core.mail.message
from django.conf import settings
from django.db import models
from django.db.models import Exists, ExpressionWrapper, F, OuterRef, Subquery, Sum
from django.db.models import (
Count,
Exists,
ExpressionWrapper,
F,
OuterRef,
Subquery,
Sum,
)
from django.utils import timezone
@ -419,6 +427,7 @@ class EventExtManager(models.Manager["EventExt"]):
super()
.get_queryset()
.annotate(
Count("meeting_times"),
duration=Subquery(
EventMeetingTime.objects.filter(event=OuterRef("pk"))
.values("event__pk")

View File

@ -35,7 +35,7 @@
<td>{{ event.category }}</td>
<td>{{ event.count }}</td>
<td>{{ event.cap }}</td>
<td>{{ event.meeting_times.count }}</td>
<td>{{ event.meeting_times__count }}</td>
<td>{{ event.duration|duration_as_hours }}</td>
<td>{{ event.person_hours|duration_as_hours }}</td>
</tr>