-
-
Notifications
You must be signed in to change notification settings - Fork 491
/
clock.rb
39 lines (34 loc) · 1.01 KB
/
clock.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
require "rake"
require "clockwork"
require "clockwork/database_events"
require_relative "config/boot"
require_relative "config/environment"
module Clockwork
handler do |job|
puts "Running #{job}"
end
DATA_TYPES = %w[Distribution Purchase Donation]
every(1.day, "Cache historical data", at: "03:00") do
Organization.is_active.each do |org|
DATA_TYPES.each do |type|
Rails.logger.info("Queuing up #{type} cache data for #{org.name}")
HistoricalDataCacheJob.perform_later(org_id: org.id, type: type)
end
end
Rails.logger.info("Done!")
end
every(1.day, "Periodically reset seed data in staging", at: "00:00") do
if ENV["RAILS_ENV"] == "staging"
rake = Rake.application
rake.init
rake.load_rakefile
rake["reset_demo"].invoke
end
end
every(4.hours, "Backup prod DB to Azure blob storage", if: lambda { |_| Rails.env.production? }) do
rake = Rake.application
rake.init
rake.load_rakefile
rake["backup_db_rds"].invoke
end
end