Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

misc: Add missing require in DailyUsages::FillHistoryService #2846

Merged
merged 1 commit into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ gem "strong_migrations"
gem "bigdecimal"
gem "countries"
gem "money-rails"
gem "timecop", require: false
gem "tzinfo-data", platforms: %i[mingw mswin x64_mingw jruby]

# GraphQL
Expand Down Expand Up @@ -90,12 +91,11 @@ gem "valvat", require: false
# Data Export
gem "csv", "~> 3.0"

gem 'lago-expression', github: 'getlago/lago-expression', glob: 'expression-ruby/lago-expression.gemspec'
gem "lago-expression", github: "getlago/lago-expression", glob: "expression-ruby/lago-expression.gemspec"

group :development, :test, :staging do
gem "factory_bot_rails"
gem "faker"
gem "timecop"
end

group :development, :test do
Expand Down
2 changes: 2 additions & 0 deletions app/services/daily_usages/fill_history_service.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

require "timecop"
nudded marked this conversation as resolved.
Show resolved Hide resolved

module DailyUsages
class FillHistoryService < BaseService
def initialize(subscription:, from_datetime:)
Expand Down
4 changes: 1 addition & 3 deletions lib/tasks/daily_usages.rake
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# frozen_string_literal: true

require 'timecop'

namespace :daily_usages do
desc "Fill past daily usage"
task :fill_history, [:organization_id, :days_ago] => :environment do |_task, args|
Expand All @@ -15,7 +13,7 @@ namespace :daily_usages do
subscriptions = organization.subscriptions
.where(status: [:active, :terminated])
.where.not(started_at: nil)
.where('terminated_at IS NULL OR terminated_at >= ?', days_ago)
.where("terminated_at IS NULL OR terminated_at >= ?", days_ago)
.includes(customer: :organization)

subscriptions.find_each do |subscription|
Expand Down