Add NoOp email service, /docs shortcut and fix streak timezone bug
Replace nil email service pattern with NoOpEmailService (Null Object) to eliminate nil pointer panics across all handlers. Add /docs route as a shortcut to Swagger UI. Fix streak calculation returning 0 when server timezone differs from UTC — CreatedAt was not converted to UTC before date extraction.
This commit is contained in:
@@ -10,4 +10,11 @@ type EmailMessage struct {
|
||||
type EmailService interface {
|
||||
Send(message EmailMessage) error
|
||||
HealthCheck() error
|
||||
IsEnabled() bool
|
||||
}
|
||||
|
||||
type NoOpEmailService struct{}
|
||||
|
||||
func (n *NoOpEmailService) Send(_ EmailMessage) error { return nil }
|
||||
func (n *NoOpEmailService) HealthCheck() error { return nil }
|
||||
func (n *NoOpEmailService) IsEnabled() bool { return false }
|
||||
|
||||
@@ -49,7 +49,8 @@ func buildEntryMap(entries []*entities.HabitEntry) map[string]*entities.HabitEnt
|
||||
}
|
||||
|
||||
func allScheduledDates(habit *entities.Habit, now time.Time) []time.Time {
|
||||
start := time.Date(habit.CreatedAt.Year(), habit.CreatedAt.Month(), habit.CreatedAt.Day(), 0, 0, 0, 0, time.UTC)
|
||||
createdUTC := habit.CreatedAt.UTC()
|
||||
start := time.Date(createdUTC.Year(), createdUTC.Month(), createdUTC.Day(), 0, 0, 0, 0, time.UTC)
|
||||
today := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.UTC)
|
||||
freq := string(habit.Frequency)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user