For the mailer report we have WorkReportMailer
which acts as the controller of the Application Mailer. The mailer is called
in the ExportController file.
def send_mail_report
emails = process_email
emails.each do |email|
WorkReportMailer.send_report(email.strip, current_account.cname, params[:email_type]).deliver_later
end
redirect_to hyrax.admin_stats_path(anchor: 'email_reports')
end
The following line will trigger the email via sidekiq, if we want to check the mail without sidekiq, replace deliver_later
with deliver_now!
WorkReportMailer.send_report(email.strip, current_account.cname, params[:email_type]).deliver_later
The fetching of data and processing the values as per the report format is as follows.
- We use ReportMailer service
app/services/ubiquity/report_mailer.rb
to query the records based on theemail_type
and process the data by sorting the records based on Work Type - The method for sorting the data is inside the services dir
app/services/ubiquity/fetch_mailer_report_data.rb
To generate the mail preview we have a dedicated url to generate it. '
http://ashik.localhost:3000/rails/mailers/work_report_mailer/send_report
Please make sure you have the below ENV variable to enable this feature.
# LocalEnv.yml
ENABLE_MAILER_PREVIEWS: 'true'