Replies: 1 comment 1 reply
-
Hi! Thanks for asking. What you're describing is a very common need. I want to discourage you from using scheduled jobs in this way, for exactly the reasons you describe:
I've personally solved this problem by doing this:
But, if you really did want to do future scheduled jobs, some other options are:
|
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Upon user registration, I schedule jobs in the future for a few purposes like reminding the users to confirm their email addresses. Now if a user cancels their account leaving future jobs tied to that account due, I'd like to cancel them too.
I'd like to use an
after_destroy
callback on the user model to find and cancel these scheduled jobs.How do I find these scheduled jobs using
GoodJob
though?The only way I see is using
GoodJob::Job.all
and filtering using aselect{...}
statement likeI am not sure though how efficient that is once there are a lot of jobs in the database after a while in production. Is there any more elegant way to achieve what I am trying to do?
Any idea is greatly appreciated.
Beta Was this translation helpful? Give feedback.
All reactions