On optimise la requête
on avait pleeein d'événements non récurrents mais récupérés comme tels
This commit is contained in:
parent
471bd08cd1
commit
9b4f10c1c0
@ -256,15 +256,19 @@ class CalendarList:
|
||||
startdatetime = timezone.make_aware(datetime.combine(self.c_firstdate, time.min), timezone.get_default_timezone())
|
||||
lastdatetime = timezone.make_aware(datetime.combine(self.c_lastdate, time.max), timezone.get_default_timezone())
|
||||
qs = qs.filter(
|
||||
(Q(recurrence_dtend__isnull=True) & Q(recurrence_dtstart__lte=lastdatetime))
|
||||
| (
|
||||
Q(recurrence_dtend__isnull=False)
|
||||
& ~(
|
||||
Q(recurrence_dtstart__gt=lastdatetime)
|
||||
| Q(recurrence_dtend__lt=startdatetime)
|
||||
(Q(recurrences__isnull=False) &
|
||||
(Q(recurrence_dtend__isnull=True) & Q(recurrence_dtstart__isnull=False) & Q(recurrence_dtstart__lte=lastdatetime))
|
||||
| (
|
||||
Q(recurrence_dtend__isnull=False)
|
||||
& ~(
|
||||
Q(recurrence_dtstart__gt=lastdatetime)
|
||||
| Q(recurrence_dtend__lt=startdatetime)
|
||||
)
|
||||
)
|
||||
)
|
||||
| (Q(start_day__lte=self.c_lastdate) & ((Q(end_day__isnull=True) & Q(start_day__gte=self.c_firstdate)) | Q(end_day__gte=self.c_firstdate)))
|
||||
| (Q(start_day__lte=self.c_lastdate) & # start before the end of the desired period
|
||||
((Q(end_day__isnull=True) & Q(start_day__gte=self.c_firstdate)) # end after the begining of desired period
|
||||
| (Q(end_day__isnull=False) & Q(end_day__gte=self.c_firstdate))))
|
||||
).filter(
|
||||
Q(other_versions__isnull=True) |
|
||||
Q(other_versions__representative=F('pk')) |
|
||||
|
Loading…
x
Reference in New Issue
Block a user