M9.1: wire sync logging into all mutation paths
- Add LogClosedDayDelete and LogClosedWeekDelete to SyncStore - Inject syncStore into EntryService; log Start, Stop, StopByID, Update, CreateInterval, Delete, AutoStopStalledEntries - Inject syncStore into DayService; log CloseDay, MarkDay, ReopenDay, and the recomputeWeek closed-week upsert - Inject syncStore into SettingsService; log Upsert, UpdateSettings, DeleteSettings - Add LogClosedWeek/LogClosedWeekDelete calls in WeekService.CloseWeek and ReopenWeek - Update main.go and all service test helpers for new constructor signatures - All Go tests and 19 Vitest tests pass
This commit is contained in:
@@ -22,11 +22,12 @@ var (
|
||||
|
||||
// SettingsService manages settings with effective-from history.
|
||||
type SettingsService struct {
|
||||
store *store.SettingsStore
|
||||
store *store.SettingsStore
|
||||
syncStore *store.SyncStore
|
||||
}
|
||||
|
||||
func NewSettingsService(s *store.SettingsStore) *SettingsService {
|
||||
return &SettingsService{store: s}
|
||||
func NewSettingsService(s *store.SettingsStore, syncStore *store.SyncStore) *SettingsService {
|
||||
return &SettingsService{store: s, syncStore: syncStore}
|
||||
}
|
||||
|
||||
// Current returns settings effective as of today.
|
||||
@@ -92,6 +93,7 @@ func (s *SettingsService) Upsert(ctx context.Context, input UpsertSettingsInput)
|
||||
if err := s.store.Insert(ctx, set); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_ = s.syncStore.LogSettings(ctx, set)
|
||||
return set, nil
|
||||
}
|
||||
|
||||
@@ -138,6 +140,7 @@ func (s *SettingsService) UpdateSettings(ctx context.Context, id string, input U
|
||||
if err := s.store.Update(ctx, set); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_ = s.syncStore.LogSettings(ctx, set)
|
||||
return set, nil
|
||||
}
|
||||
|
||||
@@ -157,5 +160,9 @@ func (s *SettingsService) DeleteSettings(ctx context.Context, id string) error {
|
||||
}
|
||||
return err
|
||||
}
|
||||
return s.store.Delete(ctx, id)
|
||||
if err := s.store.Delete(ctx, id); err != nil {
|
||||
return err
|
||||
}
|
||||
_ = s.syncStore.LogSettingsDelete(ctx, id)
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user