|
|
grouped = self.env["queue.job"].read_group(
[("job_batch_id", "in", self.ids)],
["job_batch_id", "state"],
["job_batch_id", "state"],
lazy=False,
)
counts = {}
for g in grouped:
batch_id = g["job_batch_id"][0]
counts.setdefault(batch_id, {})
counts[batch_id][g["state"]] = g["__count"]
for rec in self:
by_state = counts.get(rec.id, {})
total = sum(by_state.values())
done = by_state.get("done", 0)
failed = by_state.get("failed", 0)
rec.job_count = total
rec.failed_job_count = failed
rec.finished_job_count = done
rec.completeness = done / max(1, total)
rec.failed_percentage = failed / max(1, total)
|
|