2019-05-03 06:17:27 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2013-03-10 20:51:49 +08:00
|
|
|
desc "This task is called by the Heroku scheduler add-on"
|
|
|
|
|
2017-07-28 09:20:09 +08:00
|
|
|
task enqueue_digest_emails: :environment do
|
2013-03-10 20:51:49 +08:00
|
|
|
Jobs::EnqueueDigestEmails.new.execute(nil)
|
|
|
|
end
|
|
|
|
|
2017-07-28 09:20:09 +08:00
|
|
|
task category_stats: :environment do
|
2013-03-10 20:51:49 +08:00
|
|
|
Jobs::CategoryStats.new.execute(nil)
|
|
|
|
end
|
|
|
|
|
2017-07-28 09:20:09 +08:00
|
|
|
task periodical_updates: :environment do
|
2013-03-29 01:02:59 +08:00
|
|
|
Jobs::PeriodicalUpdates.new.execute(nil)
|
2013-03-10 20:51:49 +08:00
|
|
|
end
|
|
|
|
|
2017-07-28 09:20:09 +08:00
|
|
|
task version_check: :environment do
|
2013-03-10 20:51:49 +08:00
|
|
|
Jobs::VersionCheck.new.execute(nil)
|
2017-07-28 09:20:09 +08:00
|
|
|
end
|
2017-08-26 00:19:27 +08:00
|
|
|
|
|
|
|
def time
|
|
|
|
start = Time.now
|
|
|
|
yield
|
|
|
|
puts "Elapsed #{((Time.now - start) * 1000).to_i}ms"
|
|
|
|
end
|
|
|
|
|
|
|
|
desc "run every task the scheduler knows about in that order, use only for debugging"
|
|
|
|
task 'scheduler:run_all' => :environment do
|
2018-08-01 05:12:55 +08:00
|
|
|
MiniScheduler::Manager.discover_schedules.each do |schedule|
|
2017-08-26 00:19:27 +08:00
|
|
|
puts "Running #{schedule}"
|
|
|
|
time { schedule.new.execute({}) }
|
|
|
|
end
|
|
|
|
end
|