You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey! I've just finished reading through the README and it pretty much answered all my questions. Good job (pun intended) on the documentation!
However, I was wondering if there was a way to officially expose a method to use in a rake task or job to clean up old jobs. The README suggests using:
GoodJob::Job.finished(1.day.ago).delete_all
However, the CLI task does a bit more, namely instrumenting via ActiveSupport::Notifications:
Of course I can just copy the code, but since that functionality seems to be desired behavior since it's implemented in the CLI, maybe it's a good idea to expose this directly? Would also make it easier to schedule this via GoodJob itself.
Another question would be, is there a reason why .delete_all is enough and we don't need callbacks via .destroy_all? I assume there's just no need for them as the jobs have no associations to destroy or nullify, but just wanted to make sure.
Thanks!
The text was updated successfully, but these errors were encountered:
@aried3r this is a great suggestion to move this into the public interface! GoodJob.cleanup_preserved_jobs sounds like a good place to extract this behavior and make it easier/safer for reuse.
is there a reason why .delete_all is enough
You're correct: there are no callbacks, so it's safe to simply delete them. And likely there never should be callbacks because this could be a fairly beefy resultset of thousands of jobs.
I support this if you wanted to submit a PR.
Would also make it easier to schedule this via GoodJob itself.
Yes, totally. Longer-term (just so you have a sense of where I imagine things heading) I think GoodJob will do have the capability to do its own housekeeping: scheduling a thread that will occasionally delete old jobs in the background, rather than burden the user with running the rake task. Your suggestion helps move in that direction 👍 This would also help unlock a request for GoodJob to preserve errored jobs by default, which I've deferred because it could potentially fill up someone's database unexpectedly if there wasn't also a default mechanism cleaning things up.
aried3r
added a commit
to aried3r/good_job
that referenced
this issue
Aug 30, 2021
Hey! I've just finished reading through the README and it pretty much answered all my questions. Good job (pun intended) on the documentation!
However, I was wondering if there was a way to officially expose a method to use in a rake task or job to clean up old jobs. The README suggests using:
However, the CLI task does a bit more, namely instrumenting via
ActiveSupport::Notifications
:good_job/lib/good_job/cli.rb
Lines 139 to 146 in 811fb26
Of course I can just copy the code, but since that functionality seems to be desired behavior since it's implemented in the CLI, maybe it's a good idea to expose this directly? Would also make it easier to schedule this via GoodJob itself.
Another question would be, is there a reason why
.delete_all
is enough and we don't need callbacks via.destroy_all
? I assume there's just no need for them as the jobs have no associations to destroy or nullify, but just wanted to make sure.Thanks!
The text was updated successfully, but these errors were encountered: