I have a simple job in rails that's run every 15 minutes.I am using the default Solid queue setup for jobs.
class ContinuousSearchJob < ApplicationJob
def perform
keyword = Keyword.first
if keyword
keyword.insert_playlists
end
end
end
I have the recurring.yml
to run it every 15 minutes. The issue I face is that , sometimes the job could take very long and longer than 15 minutes. And another ContinuousJob
would again queue at that point which I dont want. If one ContinuousJob
is in queue or running , I want to discard any following. There is an option to block such jobs for sometime. But there is no way to discard. How can I achieve this?
The only solution I could come up with is to destroy all in queue ContinuousJob
at the end of a running job if any exist.
Something like this logic
SolidQueue.where(class: "ContinuousJob", status: "pending").discard
But I am unable to find any ways to get all the pending jobs and discard them. Any help would be appreciated.