-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclock.rb
68 lines (51 loc) · 1.8 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# frozen_string_literal: true
require 'clockwork'
require './config/boot'
require './config/environment'
module Clockwork
handler do |job, time|
puts "Running #{job} at #{time}"
end
error_handler do |error|
Rails.logger.error(e.message)
Rails.logger.error(e.backtrace.join("\n"))
Sentry.capture_exception(error)
end
# NOTE: All clocks run every hour to take customer timezones into account
every(5.minutes, 'schedule:activate_subscriptions') do
Clock::ActivateSubscriptionsJob.perform_later
end
every(5.minutes, 'schedule:refresh_draft_invoices') do
Clock::RefreshDraftInvoicesJob.perform_later
end
every(5.minutes, 'schedule:refresh_wallets_credits') do
Clock::RefreshWalletsCreditsJob.perform_later
end
every(1.hour, 'schedule:terminate_ended_subscriptions', at: '*:05') do
Clock::TerminateEndedSubscriptionsJob.perform_later
end
every(1.hour, 'schedule:bill_customers', at: '*:10') do
Clock::SubscriptionsBillerJob.perform_later
end
every(1.hour, 'schedule:finalize_invoices', at: '*:20') do
Clock::FinalizeInvoicesJob.perform_later
end
every(1.hour, 'schedule:terminate_coupons', at: '*:30') do
Clock::TerminateCouponsJob.perform_later
end
every(1.hour, 'schedule:terminate_wallets', at: '*:45') do
Clock::TerminateWalletsJob.perform_later
end
every(1.hour, 'schedule:termination_alert', at: '*:50') do
Clock::SubscriptionsToBeTerminatedJob.perform_later
end
every(1.hour, 'schedule:top_up_wallet_interval_credits', at: '*:55') do
Clock::CreateIntervalWalletTransactionsJob.perform_later
end
every(1.day, 'schedule:clean_webhooks', at: '01:00') do
Clock::WebhooksCleanupJob.perform_later
end
every(1.hour, 'schedule:post_validate_events', at: '*:05') do
Clock::EventsValidationJob.perform_later
end
end