Skip to content

Commit

Permalink
fix: Fix task to assign subscription to events (#368)
Browse files Browse the repository at this point in the history
  • Loading branch information
vincent-pochet authored Aug 8, 2022
1 parent bd3b211 commit 31769d5
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/tasks/events.rake
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ namespace :events do
desc 'Fill missing subscription_id'
task fill_subscription: :environment do
Event.where(subscription_id: nil).find_each do |event|
event.update!(subscription_id: event.customer.active_subscription&.id)
subscription = event.customer.active_subscription || event.customer.subscriptions.order(&:created_at).last

event.update!(subscription_id: subscription.id)
end
end
end

0 comments on commit 31769d5

Please sign in to comment.