fix: result report email
This commit is contained in:
parent
9d33625198
commit
9900113e33
|
|
@ -527,18 +527,18 @@ func buildHeadlineAndMessage(counts domain.ResultLog) (string, string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func buildHeadlineAndMessageEmail(counts domain.ResultLog, user domain.User) (string, string, string) {
|
func buildHeadlineAndMessageEmail(counts domain.ResultLog, user domain.User) (string, string, string) {
|
||||||
totalIssues := counts.StatusNotFinishedCount + counts.StatusToBeFixedCount +
|
totalIssues := counts.StatusNotFinishedCount + counts.StatusToBeFixedCount +
|
||||||
counts.StatusPostponedCount + counts.StatusRemovedCount
|
counts.StatusPostponedCount + counts.StatusRemovedCount
|
||||||
totalEvents := counts.StatusEndedCount + counts.StatusNotFinishedCount +
|
totalEvents := counts.StatusEndedCount + counts.StatusNotFinishedCount +
|
||||||
counts.StatusToBeFixedCount + counts.StatusPostponedCount + counts.StatusRemovedCount
|
counts.StatusToBeFixedCount + counts.StatusPostponedCount + counts.StatusRemovedCount
|
||||||
totalBets := counts.StatusEndedBets + counts.StatusNotFinishedBets +
|
totalBets := counts.StatusEndedBets + counts.StatusNotFinishedBets +
|
||||||
counts.StatusPostponedBets + counts.StatusRemovedBets + counts.StatusToBeFixedBets
|
counts.StatusPostponedBets + counts.StatusRemovedBets + counts.StatusToBeFixedBets
|
||||||
|
|
||||||
greeting := fmt.Sprintf("Hi %s %s,", user.FirstName, user.LastName)
|
greeting := fmt.Sprintf("Hi %s %s,", user.FirstName, user.LastName)
|
||||||
|
|
||||||
if totalIssues == 0 {
|
if totalIssues == 0 {
|
||||||
headline := "✅ Daily Results Report — All Events Processed Successfully"
|
headline := "✅ Daily Results Report — All Events Processed Successfully"
|
||||||
plain := fmt.Sprintf(`%s
|
plain := fmt.Sprintf(`%s
|
||||||
|
|
||||||
Daily Results Summary:
|
Daily Results Summary:
|
||||||
- %d Ended Events
|
- %d Ended Events
|
||||||
|
|
@ -549,7 +549,7 @@ All events were processed successfully, and no issues were detected.
|
||||||
Best regards,
|
Best regards,
|
||||||
The System`, greeting, counts.StatusEndedCount, totalBets)
|
The System`, greeting, counts.StatusEndedCount, totalBets)
|
||||||
|
|
||||||
html := fmt.Sprintf(`<p>%s</p>
|
html := fmt.Sprintf(`<p>%s</p>
|
||||||
<h2>Daily Results Summary</h2>
|
<h2>Daily Results Summary</h2>
|
||||||
<ul>
|
<ul>
|
||||||
<li><strong>%d Ended Events</strong></li>
|
<li><strong>%d Ended Events</strong></li>
|
||||||
|
|
@ -557,48 +557,48 @@ The System`, greeting, counts.StatusEndedCount, totalBets)
|
||||||
</ul>
|
</ul>
|
||||||
<p>All events were processed successfully, and no issues were detected.</p>
|
<p>All events were processed successfully, and no issues were detected.</p>
|
||||||
<p>Best regards,<br>The System</p>`,
|
<p>Best regards,<br>The System</p>`,
|
||||||
greeting, counts.StatusEndedCount, totalBets)
|
greeting, counts.StatusEndedCount, totalBets)
|
||||||
|
|
||||||
return headline, plain, html
|
return headline, plain, html
|
||||||
}
|
}
|
||||||
|
|
||||||
partsPlain := []string{}
|
partsPlain := []string{}
|
||||||
partsHTML := []string{}
|
partsHTML := []string{}
|
||||||
|
|
||||||
if counts.StatusNotFinishedCount > 0 {
|
if counts.StatusNotFinishedCount > 0 {
|
||||||
partsPlain = append(partsPlain,
|
partsPlain = append(partsPlain,
|
||||||
fmt.Sprintf("- %d Unresolved Events (%d Bets)", counts.StatusNotFinishedCount, counts.StatusNotFinishedBets))
|
fmt.Sprintf("- %d Unresolved Events (%d Bets)", counts.StatusNotFinishedCount, counts.StatusNotFinishedBets))
|
||||||
partsHTML = append(partsHTML,
|
partsHTML = append(partsHTML,
|
||||||
fmt.Sprintf("<li><strong>%d Unresolved Events</strong> (%d Bets)</li>", counts.StatusNotFinishedCount, counts.StatusNotFinishedBets))
|
fmt.Sprintf("<li><strong>%d Unresolved Events</strong> (%d Bets)</li>", counts.StatusNotFinishedCount, counts.StatusNotFinishedBets))
|
||||||
}
|
}
|
||||||
if counts.StatusToBeFixedCount > 0 {
|
if counts.StatusToBeFixedCount > 0 {
|
||||||
partsPlain = append(partsPlain,
|
partsPlain = append(partsPlain,
|
||||||
fmt.Sprintf("- %d Requires Review (%d Bets)", counts.StatusToBeFixedCount, counts.StatusToBeFixedBets))
|
fmt.Sprintf("- %d Requires Review (%d Bets)", counts.StatusToBeFixedCount, counts.StatusToBeFixedBets))
|
||||||
partsHTML = append(partsHTML,
|
partsHTML = append(partsHTML,
|
||||||
fmt.Sprintf("<li><strong>%d Requires Review</strong> (%d Bets)</li>", counts.StatusToBeFixedCount, counts.StatusToBeFixedBets))
|
fmt.Sprintf("<li><strong>%d Requires Review</strong> (%d Bets)</li>", counts.StatusToBeFixedCount, counts.StatusToBeFixedBets))
|
||||||
}
|
}
|
||||||
if counts.StatusPostponedCount > 0 {
|
if counts.StatusPostponedCount > 0 {
|
||||||
partsPlain = append(partsPlain,
|
partsPlain = append(partsPlain,
|
||||||
fmt.Sprintf("- %d Postponed Events (%d Bets)", counts.StatusPostponedCount, counts.StatusPostponedBets))
|
fmt.Sprintf("- %d Postponed Events (%d Bets)", counts.StatusPostponedCount, counts.StatusPostponedBets))
|
||||||
partsHTML = append(partsHTML,
|
partsHTML = append(partsHTML,
|
||||||
fmt.Sprintf("<li><strong>%d Postponed Events</strong> (%d Bets)</li>", counts.StatusPostponedCount, counts.StatusPostponedBets))
|
fmt.Sprintf("<li><strong>%d Postponed Events</strong> (%d Bets)</li>", counts.StatusPostponedCount, counts.StatusPostponedBets))
|
||||||
}
|
}
|
||||||
if counts.StatusRemovedCount > 0 {
|
if counts.StatusRemovedCount > 0 {
|
||||||
partsPlain = append(partsPlain,
|
partsPlain = append(partsPlain,
|
||||||
fmt.Sprintf("- %d Discarded Events (%d Bets)", counts.StatusRemovedCount, counts.StatusRemovedBets))
|
fmt.Sprintf("- %d Discarded Events (%d Bets)", counts.StatusRemovedCount, counts.StatusRemovedBets))
|
||||||
partsHTML = append(partsHTML,
|
partsHTML = append(partsHTML,
|
||||||
fmt.Sprintf("<li><strong>%d Discarded Events</strong> (%d Bets)</li>", counts.StatusRemovedCount, counts.StatusRemovedBets))
|
fmt.Sprintf("<li><strong>%d Discarded Events</strong> (%d Bets)</li>", counts.StatusRemovedCount, counts.StatusRemovedBets))
|
||||||
}
|
}
|
||||||
if counts.StatusEndedCount > 0 {
|
if counts.StatusEndedCount > 0 {
|
||||||
partsPlain = append(partsPlain,
|
partsPlain = append(partsPlain,
|
||||||
fmt.Sprintf("- %d Successfully Ended Events (%d Bets)", counts.StatusEndedCount, counts.StatusEndedBets))
|
fmt.Sprintf("- %d Successfully Ended Events (%d Bets)", counts.StatusEndedCount, counts.StatusEndedBets))
|
||||||
partsHTML = append(partsHTML,
|
partsHTML = append(partsHTML,
|
||||||
fmt.Sprintf("<li><strong>%d Successfully Ended Events</strong> (%d Bets)</li>", counts.StatusEndedCount, counts.StatusEndedBets))
|
fmt.Sprintf("<li><strong>%d Successfully Ended Events</strong> (%d Bets)</li>", counts.StatusEndedCount, counts.StatusEndedBets))
|
||||||
}
|
}
|
||||||
|
|
||||||
headline := "⚠️ Daily Results Report — Review Required"
|
headline := "⚠️ Daily Results Report — Review Required"
|
||||||
|
|
||||||
plain := fmt.Sprintf(`%s
|
plain := fmt.Sprintf(`%s
|
||||||
|
|
||||||
Daily Results Summary:
|
Daily Results Summary:
|
||||||
%s
|
%s
|
||||||
|
|
@ -612,13 +612,13 @@ Some events require your attention. Please log into the admin dashboard to revie
|
||||||
|
|
||||||
Best regards,
|
Best regards,
|
||||||
The System`,
|
The System`,
|
||||||
greeting,
|
greeting,
|
||||||
strings.Join(partsPlain, "\n"),
|
strings.Join(partsPlain, "\n"),
|
||||||
totalEvents,
|
totalEvents,
|
||||||
totalBets,
|
totalBets,
|
||||||
)
|
)
|
||||||
|
|
||||||
html := fmt.Sprintf(`<p>%s</p>
|
html := fmt.Sprintf(`<p>%s</p>
|
||||||
<h2>Daily Results Summary</h2>
|
<h2>Daily Results Summary</h2>
|
||||||
<ul>
|
<ul>
|
||||||
%s
|
%s
|
||||||
|
|
@ -628,18 +628,17 @@ The System`,
|
||||||
<li><strong>%d Events Processed</strong></li>
|
<li><strong>%d Events Processed</strong></li>
|
||||||
<li><strong>%d Total Bets</strong></li>
|
<li><strong>%d Total Bets</strong></li>
|
||||||
</ul>
|
</ul>
|
||||||
<p><strong>Next Steps:</strong><br>Some events require your attention. Please <a href="https://your-dashboard-url.example">log into the admin dashboard</a> to review pending issues.</p>
|
<p><strong>Next Steps:</strong><br>Some events require your attention. Please <a href="https://admin.fortunebets.net">log into the admin dashboard</a> to review pending issues.</p>
|
||||||
<p>Best regards,<br>The System</p>`,
|
<p>Best regards,<br>The System</p>`,
|
||||||
greeting,
|
greeting,
|
||||||
strings.Join(partsHTML, "\n"),
|
strings.Join(partsHTML, "\n"),
|
||||||
totalEvents,
|
totalEvents,
|
||||||
totalBets,
|
totalBets,
|
||||||
)
|
)
|
||||||
|
|
||||||
return headline, plain, html
|
return headline, plain, html
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func (s *Service) SendAdminResultStatusErrorNotification(
|
func (s *Service) SendAdminResultStatusErrorNotification(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
counts domain.ResultLog,
|
counts domain.ResultLog,
|
||||||
|
|
@ -660,7 +659,6 @@ func (s *Service) SendAdminResultStatusErrorNotification(
|
||||||
}
|
}
|
||||||
|
|
||||||
headline, message := buildHeadlineAndMessage(counts)
|
headline, message := buildHeadlineAndMessage(counts)
|
||||||
|
|
||||||
|
|
||||||
notification := &domain.Notification{
|
notification := &domain.Notification{
|
||||||
ErrorSeverity: domain.NotificationErrorSeverityHigh,
|
ErrorSeverity: domain.NotificationErrorSeverityHigh,
|
||||||
|
|
|
||||||
2
makefile
2
makefile
|
|
@ -79,7 +79,7 @@ logs:
|
||||||
@mkdir -p logs
|
@mkdir -p logs
|
||||||
db-up: | logs
|
db-up: | logs
|
||||||
@mkdir -p logs
|
@mkdir -p logs
|
||||||
@docker compose up -d postgres migrate mongo redis --wait migrate
|
@docker compose up -d postgres migrate mongo redis
|
||||||
@docker logs fortunebet-backend-postgres-1 > logs/postgres.log 2>&1 &
|
@docker logs fortunebet-backend-postgres-1 > logs/postgres.log 2>&1 &
|
||||||
.PHONY: db-down
|
.PHONY: db-down
|
||||||
db-down:
|
db-down:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user