UX: Warn in /logs when PM is not sent (#271)

This commit is contained in:
Natalie Tay 2023-12-11 11:08:08 +08:00 committed by GitHub
parent 3dd5ad0f9c
commit 9bd70192b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 1 deletions

View File

@ -116,7 +116,13 @@ after_initialize do
DiscourseDataExplorer::ReportGenerator.new(automation.last_updated_by_id)
report_pms = data_explorer_report.generate(query_id, query_params, recipients)
report_pms.each { |pm| utils.send_pm(pm, automation_id: automation.id) }
report_pms.each do |pm|
begin
utils.send_pm(pm, automation_id: automation.id)
rescue ActiveRecord::RecordNotSaved => e
Rails.logger.warn "#{DiscourseDataExplorer::PLUGIN_NAME} - couldn't send PM for automation #{automation.id}: #{e.message}"
end
end
end
end
end