Check if a task is pending the moment before executing it instead of checking for all pending tasks, then running all of them.
In the current version, when you run 'rake after_party:run', it collects all the pending tasks and queues them up. In the suggested change, it also does another check of each task before executing that task.
Why
We have a use case where we want to skip existing after_party tasks when starting a new environment, but then run all subsequent after party tasks. We accomplish this with something like this:
namespace :after_party do
desc 'Deployment task: mark_all_tasks_run'
task mark_all_tasks_run: :environment do
Dir.glob("#{Rails.root}/lib/tasks/deployment/*").each do |file_name|
puts "Marking #{file_name} as already run."
AfterParty::TaskRecord.create(version: AfterParty::TaskRecorder.new(file_name.split('/').last).timestamp)
end
AfterParty::TaskRecord
.create version: AfterParty::TaskRecorder.new(__FILE__).timestamp
end
end
Description
Check if a task is pending the moment before executing it instead of checking for all pending tasks, then running all of them.
In the current version, when you run 'rake after_party:run', it collects all the pending tasks and queues them up. In the suggested change, it also does another check of each task before executing that task.
Why
We have a use case where we want to skip existing after_party tasks when starting a new environment, but then run all subsequent after party tasks. We accomplish this with something like this: