aboutsummaryrefslogtreecommitdiffstats
path: root/src/booking
diff options
context:
space:
mode:
authorParker Berberian <pberberian@iol.unh.edu>2019-06-21 10:04:38 -0400
committerParker Berberian <pberberian@iol.unh.edu>2019-06-21 10:04:38 -0400
commite621a5182f387ab2b666e4c65e655b56139998d3 (patch)
tree1216d1846cb49347efd723f92839a10c77a5643f /src/booking
parente449050bc3b42ee44dc8d651036212541d3bcf36 (diff)
Prefetches Collaborators
Prefetches collaborators to further reduce database accesses Change-Id: I5a976c4e17e20ca463576178371f70e59551b576 Signed-off-by: Parker Berberian <pberberian@iol.unh.edu>
Diffstat (limited to 'src/booking')
-rw-r--r--src/booking/stats.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/booking/stats.py b/src/booking/stats.py
index 62ba648..383723a 100644
--- a/src/booking/stats.py
+++ b/src/booking/stats.py
@@ -32,7 +32,7 @@ class StatisticsManager(object):
now = datetime.datetime.now(pytz.utc)
delta = datetime.timedelta(days=span)
end = now - delta
- bookings = Booking.objects.filter(start__lte=now, end__gte=end)
+ bookings = Booking.objects.filter(start__lte=now, end__gte=end).prefetch_related("collaborators")
for booking in bookings: # collect data from each booking
user_list = [u.pk for u in booking.collaborators.all()]
user_list.append(booking.owner.pk)