Skip to content

Commit

Permalink
Merge pull request rubyforgood#5542 from rubyforgood/set_case_contact…
Browse files Browse the repository at this point in the history
…s_as_active

let rake task succeed
  • Loading branch information
compwron authored Feb 25, 2024
2 parents 8928bf1 + 52bb7d6 commit 48925a1
Showing 1 changed file with 15 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,30 @@ namespace :after_party do
desc "Deployment task: set_case_contacts_as_active"
task set_case_contacts_as_active: :environment do
puts "Running deploy task 'set_case_contacts_as_active'"
require "bugsnag"
Bugsnag.configure do |config|
config.api_key = ENV["BUGSNAG_API_KEY"]
config.ignore_classes << ActiveRecord::RecordNotFound
config.release_stage = ENV["HEROKU_APP_NAME"] || ENV["APP_ENVIRONMENT"]

callback = proc do |event|
event.set_user(current_user&.id, current_user&.email)
end

config.add_on_error(callback)
end
CaseContact.where.not(casa_case_id: nil).each do |cc|
p cc.id
cc.additional_expenses.each do |additional_expense|
additional_expense.update!(other_expenses_describe: "No description given") unless additional_expense.other_expenses_describe
success = additional_expense.update(other_expenses_describe: "No description given") unless additional_expense.other_expenses_describe
if !success
Bugsnag.notify("Failed to update additional expense #{additional_expense.id} with errors: #{additional_expense.error_messages}")
end
end

cc.update!(status: "active", draft_case_ids: [cc.casa_case_id])
rescue => e
begin
require "bugsnag"
Bugsnag.configure do |config|
config.api_key = ENV["BUGSNAG_API_KEY"]
config.ignore_classes << ActiveRecord::RecordNotFound
config.release_stage = ENV["HEROKU_APP_NAME"] || ENV["APP_ENVIRONMENT"]

callback = proc do |event|
event.set_user(current_user&.id, current_user&.email)
end

config.add_on_error(callback)
end

Bugsnag.notify(e)
rescue => e2
p e2
Expand Down

0 comments on commit 48925a1

Please sign in to comment.