Files
honeyDueAPI/internal/worker/jobs/handler_helpers.go
Trey T bec880886b Coverage priorities 1-5: test pure functions, extract interfaces, mock-based handler tests
- Priority 1: Test NewSendEmailTask + NewSendPushTask (5 tests)
- Priority 2: Test customHTTPErrorHandler — all 15+ branches (21 tests)
- Priority 3: Extract Enqueuer interface + payload builders in worker pkg (5 tests)
- Priority 4: Extract ClassifyFile/ComputeRelPath in migrate-encrypt (6 tests)
- Priority 5: Define Handler interfaces, refactor to accept them, mock-based tests (14 tests)
- Fix .gitignore: /worker instead of worker to stop ignoring internal/worker/

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-01 20:30:09 -05:00

40 lines
1.1 KiB
Go

package jobs
import (
"fmt"
"strings"
"github.com/treytartt/honeydue-api/internal/models"
)
// BuildDigestMessage constructs the daily digest notification text.
func BuildDigestMessage(overdueCount, dueThisWeekCount int) (title, body string) {
title = "Daily Task Summary"
if overdueCount > 0 && dueThisWeekCount > 0 {
body = fmt.Sprintf("You have %d overdue task(s) and %d task(s) due this week", overdueCount, dueThisWeekCount)
} else if overdueCount > 0 {
body = fmt.Sprintf("You have %d overdue task(s) that need attention", overdueCount)
} else {
body = fmt.Sprintf("You have %d task(s) due this week", dueThisWeekCount)
}
return
}
// IsOverdueStage checks if a reminder stage string represents overdue.
func IsOverdueStage(stage string) bool {
return strings.HasPrefix(stage, "overdue")
}
// ExtractFrequencyDays gets interval days from a task's frequency.
func ExtractFrequencyDays(t *models.Task) *int {
if t.Frequency != nil && t.Frequency.Days != nil {
days := *t.Frequency.Days
return &days
}
if t.CustomIntervalDays != nil {
days := *t.CustomIntervalDays
return &days
}
return nil
}