Skip to content

Commit

Permalink
rake task improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
forsbergplustwo committed Sep 21, 2023
1 parent d9246af commit 66d4b9e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions app/models/import.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class Import < ApplicationRecord
scope :in_progress, -> { where(status: %i[scheduled importing calculating]) }

def schedule
return unless draft?
scheduled!
ImportPaymentsJob.perform_later(import: self)
end
Expand Down
2 changes: 1 addition & 1 deletion lib/tasks/create_initial_imports.rake
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ task create_initial_imports: :environment do
User.find_each do |user|
import = user.imports.create!(
source: Import.sources[:shopify_payments_api]
status: Import.statuses[:completed]
)
user.metrics.update_all(import_id: import.id) if user.metrics.any?
user.payments.update_all(import_id: import.id) if user.payments.any?
import.completed!
end
end

0 comments on commit 66d4b9e

Please sign in to comment.