Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions queue_job_batch/models/queue_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,17 @@ def write(self, vals):
# to work with the same batch
batch.with_delay(identity_key=identity_exact).check_state()
return super().write(vals)

def autovacuum(self):
"""Delete batches if all jobs are unlink after job autovacuum
Called from a cron.
"""

ret = super().autovacuum()
batches = self.env["queue.job.batch"].search([("job_ids", "=", False)])

for batch in batches:
if not batch.job_ids:
batch.unlink()

return ret
Loading