Skip to content

Commit

Permalink
fix(daily_usage): Set thread safe config for daily_usage history job (#…
Browse files Browse the repository at this point in the history
…2950)

This job is used to backfill history daily_usage via
`DailyUsages::FillHistoryService` when enabling the revenue analytics
features.

NOTE: This service is not indented to be used in production-job, but to
be called from the `daily_usages:fill_history` rake task.
  • Loading branch information
vincent-pochet authored Dec 12, 2024
1 parent 6518dc6 commit 8f7efb2
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/services/daily_usages/fill_history_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def call
next if date == Time.zone.today ||
DailyUsage.refreshed_at_in_timezone(datetime).where(subscription_id: subscription.id).exists?

Timecop.thread_safe = true
Timecop.freeze(datetime + 5.minutes) do
usage = Invoices::CustomerUsageService.call(
customer: subscription.customer,
Expand Down Expand Up @@ -62,7 +63,7 @@ def call
if subscription.terminated?
invoice = subscription.invoices
.joins(:invoice_subscriptions)
.where(invoice_subscriptions: {invoicing_reason: 'subscription_terminating'})
.where(invoice_subscriptions: {invoicing_reason: "subscription_terminating"})
.first

if invoice.present?
Expand Down

0 comments on commit 8f7efb2

Please sign in to comment.