[FIX] calendar: only make leaf evaluation when necessary
A little optimisation to avoid one more query when we have no recuring event, and only evaluate leaf of recuring event.
This commit is contained in:
@@ -1110,10 +1110,11 @@ class Meeting(models.Model):
|
||||
order_fields.append('id')
|
||||
|
||||
leaf_evaluations = None
|
||||
recurrent_ids = [meeting.id for meeting in self if meeting.recurrency and meeting.rrule]
|
||||
#compose a query of the type SELECT id, condition1 as domain1, condition2 as domaine2
|
||||
#This allows to load leaf interpretation of the where clause in one query
|
||||
#leaf_evaluations is then used when running custom interpretation of domain for recuring events
|
||||
if self:
|
||||
if self and recurrent_ids:
|
||||
select_fields = ["id"]
|
||||
where_params_list = []
|
||||
for pos, arg in enumerate(domain):
|
||||
@@ -1124,7 +1125,7 @@ class Meeting(models.Model):
|
||||
where_params_list += where_params
|
||||
if len(select_fields) > 1:
|
||||
query = "SELECT %s FROM calendar_event WHERE id in %%s" % (", ".join(select_fields)) # could be improved by only taking event with recurency ?
|
||||
where_params_list += [tuple(self.ids)]
|
||||
where_params_list += [tuple(recurrent_ids)]
|
||||
self._cr.execute(query, where_params_list)
|
||||
leaf_evaluations = dict([(row['id'], row) for row in self._cr.dictfetchall()])
|
||||
result_data = []
|
||||
|
||||
Reference in New Issue
Block a user