Skip to content

A platform for community discussion. Free, open, simple.

FEATURE: include report title in PM subject and filename

Arpit Jalan4f55fbfefa74
diff --git a/app/jobs/regular/export_csv_file.rb b/app/jobs/regular/export_csv_file.rb
index d9bab1209bd..a95e43a2354 100644
--- a/app/jobs/regular/export_csv_file.rb
+++ b/app/jobs/regular/export_csv_file.rb
@@ -32,10 +32,18 @@ module Jobs
file_name_prefix = if @entity == "user_archive"
"#{@entity.split('_').join('-')}-#{@current_user.username}-#{Time.now.strftime("%y%m%d-%H%M%S")}"
+ elsif @entity == "report" && @extra[:name].present?
+ "#{@extra[:name].split('_').join('-')}-#{Time.now.strftime("%y%m%d-%H%M%S")}"
else
"#{@entity.split('_').join('-')}-#{Time.now.strftime("%y%m%d-%H%M%S")}"
end
+ export_title = if @entity == "report" && @extra[:name].present?
+ I18n.t("reports.#{@extra[:name]}.title")
+ else
+ @entity.split('_').join(' ').titleize
+ end
+
user_export = UserExport.create(file_name: file_name_prefix, user_id: @current_user.id)
file_name = "#{file_name_prefix}-#{user_export.id}.csv"
absolute_path = "#{UserExport.base_directory}/#{file_name}"
@@ -77,7 +85,7 @@ module Jobs
end
ensure
- notify_user(download_link, file_name, file_size)
+ notify_user(download_link, file_name, file_size, export_title)
end
def user_archive_export
@@ -351,7 +359,7 @@ module Jobs
screened_url_array
end
- def notify_user(download_link, file_name, file_size)
+ def notify_user(download_link, file_name, file_size, export_title)
if @current_user
if download_link.present?
SystemMessage.create_from_system_user(
@@ -359,7 +367,8 @@ module Jobs
:csv_export_succeeded,
download_link: download_link,
file_name: "#{file_name}.gz",
- file_size: file_size
+ file_size: file_size,
+ export_title: export_title
)
else
SystemMessage.create_from_system_user(@current_user, :csv_export_failed)
diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml
index 080dd41b4a0..cb699de3178 100644
--- a/config/locales/server.en.yml
+++ b/config/locales/server.en.yml
@@ -2245,7 +2245,7 @@ en:
csv_export_succeeded:
title: "CSV Export Succeeded"
- subject_template: "Data export complete"
+ subject_template: "[%{export_title}] Data export complete"
text_body_template: |
Your data export was successful! :dvd: