Skip to content

Commit

Permalink
Move clocks into recurring config
Browse files Browse the repository at this point in the history
  • Loading branch information
vincent-pochet committed Nov 28, 2024
1 parent ba18cef commit 49f43b7
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 337 deletions.
5 changes: 3 additions & 2 deletions app/jobs/clock/events_validation_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ class EventsValidationJob < ApplicationJob
include SentryCronConcern

queue_as 'clock'

unique :until_executed
limits_concurrency to: 1, key: 'post_validate_events', duration: 1.hour

def perform
return if ActiveModel::Type::Boolean.new.cast(ENV['LAGO_DISABLE_EVENTS_VALIDATION'])

# NOTE: refresh the last hour events materialized view
Scenic.database.refresh_materialized_view(
Events::LastHourMv.table_name,
Expand Down
2 changes: 2 additions & 0 deletions app/jobs/clock/refresh_wallets_ongoing_balance_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ class RefreshWalletsOngoingBalanceJob < ApplicationJob

def perform
return unless License.premium?
return if ActiveModel::Type::Boolean.new.cast(ENV['LAGO_DISABLE_WALLET_REFRESH'])
return unless ENV['LAGO_MEMCACHE_SERVERS'].present? || ENV['LAGO_REDIS_CACHE_URL'].present?

Wallet.active.ready_to_be_refreshed.find_each do |wallet|
Wallets::RefreshOngoingBalanceJob.perform_later(wallet)
Expand Down
144 changes: 0 additions & 144 deletions clock.rb

This file was deleted.

2 changes: 1 addition & 1 deletion config/initializers/rsa_keys.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

# NOTE: Turn off the private key while building assets for mission_control
unless ENV['SECRET_KEY_BASE_DUMMY'] != 1
if ENV['SECRET_KEY_BASE_DUMMY'] != 1
private_key_string = if Rails.env.development? || Rails.env.test?
File.read(Rails.root.join('.rsa_private.pem'))
else
Expand Down
72 changes: 72 additions & 0 deletions config/recurring.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,78 @@ default: &default
class: Clock::ActivateSubscriptionsJob
queue: clock
schedule: every 5 minutes
refresh_draft_invoices:
class: Clock::RefreshDraftInvoicesJob
queue: clock
schedule: every 5 minutes
terminate_ended_subscriptions:
class: Clock::TerminateEndedSubscriptionsJob
queue: clock
schedule: "5 */1 * * *"
bill_customers:
class: Clock::SubscriptionsBillerJob
queue: clock
schedule: "10 */1 * * *"
api_keys_track_usage:
class: Clock::ApiKeys::TrackUsageJob
queue: clock
schedule: "15 */1 * * *"
retry_generating_subscription_invoices:
class: Clock::RetryGeneratingSubscriptionInvoicesJob
queue: clock
schedule: "30 */1 * * *"
finalize_invoices:
class: Clock::FinalizeInvoicesJob
queue: clock
schedule: "20 */1 * * *"
mark_invoices_as_payment_overdue:
class: Clock::MarkInvoicesAsPaymentOverdueJob
queue: clock
schedule: "25 */1 * * *"
terminate_coupons:
class: Clock::TerminateCouponsJob
queue: clock
schedule: "30 */1 * * *"
bill_ended_trial_subscriptions:
class: Clock::FreeTrialSubscriptionsBillerJob
queue: clock
schedule: "35 */1 * * *"
terminate_wallets:
class: Clock::TerminateWalletsJob
queue: clock
schedule: "45 */1 * * *"
termination_alert:
class: Clock::SubscriptionsToBeTerminatedJob
queue: clock
schedule: "50 */1 * * *"
top_up_wallet_interval_credits:
class: Clock::CreateIntervalWalletTransactionsJob
queue: clock
schedule: "55 */1 * * *"
clean_webhooks:
class: Clock::WebhooksCleanupJob
queue: clock
schedule: every 1 day at 01:00
compute_daily_usage:
class: Clock::ComputeAllDailyUsagesJob
queue: clock
schedule: "15 */1 * * *"
process_dunning_campaigns:
class: Clock::ProcessDunningCampaignsJob
queue: clock
schedule: "45 */1 * * *"
refresh_lifetime_usages:
class: Clock::RefreshLifetimeUsagesJob
queue: clock
schedule: <%= "every " + (ENV.fetch('LAGO_LIFETIME_USAGE_REFRESH_INTERVAL_SECONDS', 5.minutes).to_i / 60).to_s + " minutes" %>
post_validate_events:
class: Clock::EventsValidationJob
queue: clock
schedule: "5 */1 * * *"
refresh_wallets_ongoing_balance:
class: Clock::RefreshWalletsOngoingBalanceJob
queue: clock
schedule: every 5 minutes

development:
<<: *default
Expand Down
5 changes: 0 additions & 5 deletions scripts/start.clock.dev.sh

This file was deleted.

4 changes: 0 additions & 4 deletions scripts/start.clock.sh

This file was deleted.

Loading

0 comments on commit 49f43b7

Please sign in to comment.