Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bulk delete and run immediately #4

Open
statianzo opened this issue Nov 24, 2014 · 5 comments
Open

Bulk delete and run immediately #4

statianzo opened this issue Nov 24, 2014 · 5 comments

Comments

@statianzo
Copy link
Owner

Right now if you want to remove 5 jobs, you have to click 5 trash cans. We should be able to select jobs via checkbox and perform an action.

@ericboehs
Copy link

Taking a quick look, we'd need to:

  • Add SQL[:delete_jobs] and SQL[:reschedule_jobs] in lib/que/web/sql.rb. I'd assume these would take an array of ids.
  • Implement delete and put actions for the 3 job states: running, scheduled and failing (e.g. delete "/failing" and a put "/failing"). They would go around here (or perhaps after the corresponding get).
  • These actions wouldn't be able to use the currently existing SQL queries (e.g. SQL[:failing_jobs]) unless we only supported "Delete all on this page" (it appears the statements require page size and offset as arguments). New statements (e.g. SQL[:failing_jobs_all]) for each job state filter would need to be created. The paginated and unscoped statements could probably be DRYed together.
  • These filtered requests would then take the ids from the new unpaginated statements (e.g. SQL[:failing_jobs_all]) and pass them to SQL[:delete_jobs]. This would be non-iterative so as to only use 2 sql queries (e.g. DELETE ... WHERE id in (1, 2, 3,...)). I'm not sure if the current SQL[:delete_jobs] syntax supports that so a new statement may be needed there too.

Overall this feature would take a few hours to implement especially with the proper tests. Fortunately it's primarily a backend job so no new HTML or CSS is needed (besides the delete button). Unfortunately I don't have enough time or need of this feature to implement it myself.

I hope my quick thinking through this helps someone implement this feature. I'd love to see it in my /que.

@statianzo
Copy link
Owner Author

I agree that it's low hanging fruit. Thanks for the task list, @ericboehs.

@joevandyk
Copy link
Collaborator

Seems like it would be simplest to just change the http endpoint to accept an array job ids, then delete the jobs one at a time inside a transaction.

@ericboehs
Copy link

I thought about that but I have several thousand jobs and I don't think that be very performant.

@statianzo
Copy link
Owner Author

We'd want two different endpoints, "delete" and "delete_all". "delete" could take an array of ids, and "delete_all" would perform an sql delete without an id filter. With "delete" alone, we'd have to pass down potentially several thousand ids to the client on any given page.

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

No branches or pull requests

3 participants