diff --git a/app/services/daily_usages/fill_history_service.rb b/app/services/daily_usages/fill_history_service.rb index 84909b3bceaf..731494ef6080 100644 --- a/app/services/daily_usages/fill_history_service.rb +++ b/app/services/daily_usages/fill_history_service.rb @@ -18,6 +18,7 @@ def call datetime = date.in_time_zone(subscription.customer.applicable_timezone).beginning_of_day.utc next if date == Time.zone.today || + subscription.daily_usages.where(usage_date: date - 1.day).exists? || DailyUsage.refreshed_at_in_timezone(datetime).where(subscription_id: subscription.id).exists? Timecop.thread_safe = true @@ -44,7 +45,8 @@ def call from_datetime: usage.from_datetime, to_datetime: usage.to_datetime, refreshed_at: datetime, - usage_diff: {} + usage_diff: {}, + usage_date: date - 1.day ) if date != from