@@ -129,12 +129,10 @@ class QueueJob(models.Model):
129129
130130 def init (self ):
131131 cr = self .env .cr
132- index_1 = "queue_job_identity_key_state_partial_index"
133- index_2 = "queue_job_channel_date_done_date_created_index"
134132 # Used by Job.job_record_with_same_identity_key
135133 create_index (
136134 cr ,
137- index_1 ,
135+ "queue_job_identity_key_state_partial_index" ,
138136 "queue_job" ,
139137 ["identity_key" ],
140138 where = (
@@ -146,25 +144,25 @@ def init(self):
146144 # Used by <queue.job>.autovacuum
147145 create_index (
148146 cr ,
149- index_2 ,
147+ "queue_job_channel_date_done_date_created_index" ,
150148 "queue_job" ,
151149 ["channel" , "date_done" , "date_created" ],
152150 comment = "Queue Job: index to accelerate autovacuum" ,
153151 )
154152
155153 @api .depends ("dependencies" )
156154 def _compute_dependency_graph (self ):
157- uuids = [uuid for uuid in self .mapped ("graph_uuid" ) if uuid ]
158- ids_per_graph_uuid = {}
159- if uuids :
160- rows = self .env ["queue.job" ]._read_group (
161- [("graph_uuid" , "in" , uuids )],
162- groupby = ["graph_uuid" ],
163- aggregates = ["id:recordset" ],
155+ graph_uuids = [uuid for uuid in self .mapped ("graph_uuid" ) if uuid ]
156+ if graph_uuids :
157+ ids_per_graph_uuid = dict (
158+ self .env ["queue.job" ]._read_group (
159+ [("graph_uuid" , "in" , graph_uuids )],
160+ groupby = ["graph_uuid" ],
161+ aggregates = ["id:array_agg" ],
162+ )
164163 )
165- # rows -> list of tuples: (graph_uuid, recordset)
166- for graph_uuid , recs in rows :
167- ids_per_graph_uuid [graph_uuid ] = recs .ids
164+ else :
165+ ids_per_graph_uuid = {}
168166 for record in self :
169167 if not record .graph_uuid :
170168 record .dependency_graph = {}
@@ -224,12 +222,13 @@ def _dependency_graph_vis_node(self):
224222 def _compute_graph_jobs_count (self ):
225223 graph_uuids = [uuid for uuid in self .mapped ("graph_uuid" ) if uuid ]
226224 if graph_uuids :
227- rows = self .env ["queue.job" ]._read_group (
228- [("graph_uuid" , "in" , graph_uuids )],
229- ["graph_uuid" ],
230- ["__count" ],
225+ count_per_graph_uuid = dict (
226+ self .env ["queue.job" ]._read_group (
227+ [("graph_uuid" , "in" , graph_uuids )],
228+ groupby = ["graph_uuid" ],
229+ aggregates = ["__count" ],
230+ )
231231 )
232- count_per_graph_uuid = {graph_uuid : cnt for graph_uuid , cnt in rows }
233232 else :
234233 count_per_graph_uuid = {}
235234 for record in self :
0 commit comments