Skip to content

[16.0][UPD] add empty batch remove when job vaccuum#764

Closed
julienCozo wants to merge 1 commit intoOCA:16.0from
julienCozo:16.0-add-batch-vaccuum
Closed

[16.0][UPD] add empty batch remove when job vaccuum#764
julienCozo wants to merge 1 commit intoOCA:16.0from
julienCozo:16.0-add-batch-vaccuum

Conversation

@julienCozo
Copy link
Copy Markdown

When queue jobs performing its vaccuum, delete also queue batch where job_ids is 0.

@github-actions
Copy link
Copy Markdown

There hasn't been any activity on this pull request in the past 4 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days.
If you want this PR to never become stale, please ask a PSC member to apply the "no stale" label.

@github-actions github-actions bot added the stale PR/Issue without recent activity, it'll be soon closed automatically. label Aug 31, 2025
Copy link
Copy Markdown
Contributor

@AnizR AnizR left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice initiative, I think that it makes sense to remove old batches

Can you check why your tests aren't working?

for batch in batches:
if not batch.job_ids:
batch.unlink()
self.env.cr.commit() # pylint: disable=E8102
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why doing a commit there?


Called from a cron.
"""
super().autovacuum()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A good practice is to return the call of the super:

Suggested change
super().autovacuum()
ret = super().autovacuum()
...
return ret

Called from a cron.
"""
super().autovacuum()
batches = self.env["queue.job.batch"].search([])
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
batches = self.env["queue.job.batch"].search([])
batches = self.env["queue.job.batch"].search([('job_ids','=',False)])

@julienCozo julienCozo closed this by deleting the head repository Sep 17, 2025
@remi-filament
Copy link
Copy Markdown

@julienCozo why would you remove your branch ? Could you please attend comments from @AnizR and reopen PR ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stale PR/Issue without recent activity, it'll be soon closed automatically.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants