Skip to content

Commit

Permalink
remove rescue and readd loop break
Browse files Browse the repository at this point in the history
  • Loading branch information
mwvolo committed Oct 25, 2023
1 parent 1641e3f commit 8d9ec39
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions lib/tasks/accounts/update_adopter_status.rake
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,24 @@ namespace :accounts do
loop do
users = User.where(adopter_status: nil).where.not(salesforce_contact_id: nil ).limit(250)

begin
contacts = OpenStax::Salesforce::Remote::Contact.select(
:id,
:adoption_status,
:accounts_uuid
)
.where(id: users.map(&:salesforce_contact_id))
.index_by(&:id)
contacts = OpenStax::Salesforce::Remote::Contact.select(
:id,
:adoption_status,
:accounts_uuid
)
.where(id: users.map(&:salesforce_contact_id))
.index_by(&:id)

updated_users = users.map do |user|
contact = contacts[user.salesforce_contact_id]
user.adopter_status = contact.adoption_status
end
updated_users = users.map do |user|
contact = contacts[user.salesforce_contact_id]
user.adopter_status = contact.adoption_status
end

updated_users.transaction do
updated_users.each(&:save!)
end
rescue StandardError => se
Sentry.capture_exception se
updated_users.transaction do
updated_users.each(&:save!)
end

break if users.length < 250
end
end
end

0 comments on commit 8d9ec39

Please sign in to comment.