To Send Emails that did not go out
If sparkpost gets blocked or something else dumb happens and a bunch of emails do not go out, this script can send missing powr form emails based on appFormResponses…
AppFormResponse.includes(:app).where("id > ?", 67231170).where("id < ?", 67257258).find_each do |response|
next if !response.app.active
Form::Response::SendNotificationInteractor.delay.call(app_id: response.app_id, response_id: response.id)
puts response.id
sleep(0.1)
end
from an array of form response ids
responses =
[68850944,68829189,68851351,68851159,69070476,67509875,67847535,68829275,68851253,68300699,68259833,68222715,69066334,68419212,68419050,68405085,68916695,68829064,68851092,68409301,68965769,68259833,68222715]
def SendResponses(responses, is_dry_run = false)
responses.each_with_index do |response, index|
response = AppFormResponse.find response
if is_dry_run.blank?
# puts "sending #{index} of #{responses.size} #{response.id} for #{response.app_id}"
Form::Response::SendNotificationInteractor.delay.call(
app_id: response.app_id,
response_id: response.id
)
end
puts response.id
sleep(0.1)
end
end
SendResponses(responses)