-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2081 from trade-tariff/HMRC-544-FAQ-Email-Service
HMRC-544 Added emailer service for FAQ Feedback statistics
- Loading branch information
Showing
6 changed files
with
102 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
class FaqFeedbackMailer < ApplicationMailer | ||
default to: TradeTariffBackend.support_email | ||
|
||
def faq_feedback_message | ||
mail subject: "[HMRC Online Trade Tariff Support] UK tariff - Green Lanes FAQ Feedback Report - #{TradeTariffBackend.service == 'uk' ? 'UK' : 'Northern Ireland'}", | ||
content_type: 'text/html', | ||
body: faq_feedback_statistics_body(GreenLanes::FaqFeedback.statistics) | ||
end | ||
|
||
def faq_feedback_statistics_body(results) | ||
report_html = <<~HTML | ||
<html> | ||
<body> | ||
<h2>Green Lanes FAQ Feedback Report for #{TradeTariffBackend.service == 'uk' ? 'UK' : 'Northern Ireland'}</h2> | ||
<p>A summary of FAQ Feedback Categories and Questions and their usefulness:</p> | ||
<table border="1" cellspacing="0" cellpadding="5"> | ||
<thead> | ||
<tr> | ||
<th>Category ID</th> | ||
<th>Question ID</th> | ||
<th>Useful Count</th> | ||
<th>Not Useful Count</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
HTML | ||
|
||
results.each do |row| | ||
report_html += <<~HTML | ||
<tr> | ||
<td>#{row[:category_id]}</td> | ||
<td>#{row[:question_id]}</td> | ||
<td>#{row[:useful_count]}</td> | ||
<td>#{row[:not_useful_count]}</td> | ||
</tr> | ||
HTML | ||
end | ||
|
||
report_html += <<~HTML | ||
</tbody> | ||
</table> | ||
</body> | ||
</html> | ||
HTML | ||
|
||
report_html | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
class FaqFeedbackReportWorker | ||
include Sidekiq::Worker | ||
|
||
sidekiq_options retry: 1, retry_in: 1.hour | ||
|
||
def perform(deliver_email = true) | ||
if deliver_email | ||
send_faq_feedback_report_email | ||
end | ||
end | ||
|
||
private | ||
|
||
def send_faq_feedback_report_email | ||
FaqFeedbackMailer.faq_feedback_message.deliver_now | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters