diff --git a/internal/services/result/service.go b/internal/services/result/service.go index c8e69b9..6e5075e 100644 --- a/internal/services/result/service.go +++ b/internal/services/result/service.go @@ -527,18 +527,18 @@ func buildHeadlineAndMessage(counts domain.ResultLog) (string, string) { } func buildHeadlineAndMessageEmail(counts domain.ResultLog, user domain.User) (string, string, string) { - totalIssues := counts.StatusNotFinishedCount + counts.StatusToBeFixedCount + - counts.StatusPostponedCount + counts.StatusRemovedCount - totalEvents := counts.StatusEndedCount + counts.StatusNotFinishedCount + - counts.StatusToBeFixedCount + counts.StatusPostponedCount + counts.StatusRemovedCount - totalBets := counts.StatusEndedBets + counts.StatusNotFinishedBets + - counts.StatusPostponedBets + counts.StatusRemovedBets + counts.StatusToBeFixedBets + totalIssues := counts.StatusNotFinishedCount + counts.StatusToBeFixedCount + + counts.StatusPostponedCount + counts.StatusRemovedCount + totalEvents := counts.StatusEndedCount + counts.StatusNotFinishedCount + + counts.StatusToBeFixedCount + counts.StatusPostponedCount + counts.StatusRemovedCount + totalBets := counts.StatusEndedBets + counts.StatusNotFinishedBets + + 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 { - headline := "✅ Daily Results Report — All Events Processed Successfully" - plain := fmt.Sprintf(`%s + if totalIssues == 0 { + headline := "✅ Daily Results Report — All Events Processed Successfully" + plain := fmt.Sprintf(`%s Daily Results Summary: - %d Ended Events @@ -549,7 +549,7 @@ All events were processed successfully, and no issues were detected. Best regards, The System`, greeting, counts.StatusEndedCount, totalBets) - html := fmt.Sprintf(`

%s

+ html := fmt.Sprintf(`

%s

Daily Results Summary

All events were processed successfully, and no issues were detected.

Best regards,
The System

`, - greeting, counts.StatusEndedCount, totalBets) + greeting, counts.StatusEndedCount, totalBets) - return headline, plain, html - } + return headline, plain, html + } - partsPlain := []string{} - partsHTML := []string{} + partsPlain := []string{} + partsHTML := []string{} - if counts.StatusNotFinishedCount > 0 { - partsPlain = append(partsPlain, - fmt.Sprintf("- %d Unresolved Events (%d Bets)", counts.StatusNotFinishedCount, counts.StatusNotFinishedBets)) - partsHTML = append(partsHTML, - fmt.Sprintf("
  • %d Unresolved Events (%d Bets)
  • ", counts.StatusNotFinishedCount, counts.StatusNotFinishedBets)) - } - if counts.StatusToBeFixedCount > 0 { - partsPlain = append(partsPlain, - fmt.Sprintf("- %d Requires Review (%d Bets)", counts.StatusToBeFixedCount, counts.StatusToBeFixedBets)) - partsHTML = append(partsHTML, - fmt.Sprintf("
  • %d Requires Review (%d Bets)
  • ", counts.StatusToBeFixedCount, counts.StatusToBeFixedBets)) - } - if counts.StatusPostponedCount > 0 { - partsPlain = append(partsPlain, - fmt.Sprintf("- %d Postponed Events (%d Bets)", counts.StatusPostponedCount, counts.StatusPostponedBets)) - partsHTML = append(partsHTML, - fmt.Sprintf("
  • %d Postponed Events (%d Bets)
  • ", counts.StatusPostponedCount, counts.StatusPostponedBets)) - } - if counts.StatusRemovedCount > 0 { - partsPlain = append(partsPlain, - fmt.Sprintf("- %d Discarded Events (%d Bets)", counts.StatusRemovedCount, counts.StatusRemovedBets)) - partsHTML = append(partsHTML, - fmt.Sprintf("
  • %d Discarded Events (%d Bets)
  • ", counts.StatusRemovedCount, counts.StatusRemovedBets)) - } - if counts.StatusEndedCount > 0 { - partsPlain = append(partsPlain, - fmt.Sprintf("- %d Successfully Ended Events (%d Bets)", counts.StatusEndedCount, counts.StatusEndedBets)) - partsHTML = append(partsHTML, - fmt.Sprintf("
  • %d Successfully Ended Events (%d Bets)
  • ", counts.StatusEndedCount, counts.StatusEndedBets)) - } + if counts.StatusNotFinishedCount > 0 { + partsPlain = append(partsPlain, + fmt.Sprintf("- %d Unresolved Events (%d Bets)", counts.StatusNotFinishedCount, counts.StatusNotFinishedBets)) + partsHTML = append(partsHTML, + fmt.Sprintf("
  • %d Unresolved Events (%d Bets)
  • ", counts.StatusNotFinishedCount, counts.StatusNotFinishedBets)) + } + if counts.StatusToBeFixedCount > 0 { + partsPlain = append(partsPlain, + fmt.Sprintf("- %d Requires Review (%d Bets)", counts.StatusToBeFixedCount, counts.StatusToBeFixedBets)) + partsHTML = append(partsHTML, + fmt.Sprintf("
  • %d Requires Review (%d Bets)
  • ", counts.StatusToBeFixedCount, counts.StatusToBeFixedBets)) + } + if counts.StatusPostponedCount > 0 { + partsPlain = append(partsPlain, + fmt.Sprintf("- %d Postponed Events (%d Bets)", counts.StatusPostponedCount, counts.StatusPostponedBets)) + partsHTML = append(partsHTML, + fmt.Sprintf("
  • %d Postponed Events (%d Bets)
  • ", counts.StatusPostponedCount, counts.StatusPostponedBets)) + } + if counts.StatusRemovedCount > 0 { + partsPlain = append(partsPlain, + fmt.Sprintf("- %d Discarded Events (%d Bets)", counts.StatusRemovedCount, counts.StatusRemovedBets)) + partsHTML = append(partsHTML, + fmt.Sprintf("
  • %d Discarded Events (%d Bets)
  • ", counts.StatusRemovedCount, counts.StatusRemovedBets)) + } + if counts.StatusEndedCount > 0 { + partsPlain = append(partsPlain, + fmt.Sprintf("- %d Successfully Ended Events (%d Bets)", counts.StatusEndedCount, counts.StatusEndedBets)) + partsHTML = append(partsHTML, + fmt.Sprintf("
  • %d Successfully Ended Events (%d Bets)
  • ", 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: %s @@ -612,13 +612,13 @@ Some events require your attention. Please log into the admin dashboard to revie Best regards, The System`, - greeting, - strings.Join(partsPlain, "\n"), - totalEvents, - totalBets, - ) + greeting, + strings.Join(partsPlain, "\n"), + totalEvents, + totalBets, + ) - html := fmt.Sprintf(`

    %s

    + html := fmt.Sprintf(`

    %s

    Daily Results Summary

    -

    Next Steps:
    Some events require your attention. Please log into the admin dashboard to review pending issues.

    +

    Next Steps:
    Some events require your attention. Please log into the admin dashboard to review pending issues.

    Best regards,
    The System

    `, - greeting, - strings.Join(partsHTML, "\n"), - totalEvents, - totalBets, - ) + greeting, + strings.Join(partsHTML, "\n"), + totalEvents, + totalBets, + ) - return headline, plain, html + return headline, plain, html } - func (s *Service) SendAdminResultStatusErrorNotification( ctx context.Context, counts domain.ResultLog, @@ -660,7 +659,6 @@ func (s *Service) SendAdminResultStatusErrorNotification( } headline, message := buildHeadlineAndMessage(counts) - notification := &domain.Notification{ ErrorSeverity: domain.NotificationErrorSeverityHigh, diff --git a/makefile b/makefile index 7c57002..e5e4fae 100644 --- a/makefile +++ b/makefile @@ -79,7 +79,7 @@ logs: @mkdir -p logs db-up: | 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 & .PHONY: db-down db-down: