feat(task): task enqueueing a maintenance task runnable on deploy
This commit is contained in:
parent
2127f8cef1
commit
cae5d8afed
4 changed files with 92 additions and 0 deletions
24
app/tasks/maintenance/concerns/runnable_on_deploy_concern.rb
Normal file
24
app/tasks/maintenance/concerns/runnable_on_deploy_concern.rb
Normal file
|
@ -0,0 +1,24 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Maintenance
|
||||
module RunnableOnDeployConcern
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
class_methods do
|
||||
def run_on_first_deploy
|
||||
@run_on_first_deploy = true
|
||||
end
|
||||
|
||||
def run_on_deploy?
|
||||
return false unless @run_on_first_deploy
|
||||
|
||||
task = MaintenanceTasks::TaskDataShow.new(name)
|
||||
|
||||
return false if task.completed_runs.not_errored.any?
|
||||
return false if task.active_runs.any?
|
||||
|
||||
true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue