Skip to content

Commit

Permalink
Cleanup jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
forsbergplustwo committed Aug 28, 2023
1 parent bab861a commit cf74c5b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
1 change: 0 additions & 1 deletion app/controllers/home_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,4 @@ def rename_app
end
redirect_to URI(request.referer).path
end

end
2 changes: 1 addition & 1 deletion app/jobs/import_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def perform(user_id:, import_type: nil)
end

# Payments must be imported fully before metrics can be calculated
ImportMetricsJob.perform_later(user.id)
ImportMetricsJob.perform_later(user_id: user.id)
rescue => e
user&.update(import: "Failed", import_status: 100)
raise e
Expand Down
10 changes: 5 additions & 5 deletions app/jobs/import_metrics_job.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
class ImportMetricsJob < ApplicationJob
queue_as :default

def perform(current_user_id)
return unless current_user_id
current_user = User.find(current_user_id)
def perform(user_id:)
user = User.find(user_id)
return unless user

PaymentHistory.calculate_metrics(current_user)
PaymentHistory.calculate_metrics(user)
rescue => e
current_user&.update(import: "Failed", import_status: 100)
user&.update(import: "Failed", import_status: 100)
raise e
end
end

0 comments on commit cf74c5b

Please sign in to comment.