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:
2026-04-30 22:57:02 +02:00
parent d8366f5c25
commit a8a4ea0d4f
9 changed files with 82 additions and 30 deletions

View File

@@ -150,6 +150,12 @@ func (s *SyncStore) LogClosedDay(ctx context.Context, d *domain.ClosedDay) error
return s.log(ctx, "closed_days", d.DayKey, "upsert", string(payload))
}
// LogClosedDayDelete appends a closed_day delete to the sync log.
func (s *SyncStore) LogClosedDayDelete(ctx context.Context, dayKey string) error {
payload := fmt.Sprintf(`{"day_key":%q}`, dayKey)
return s.log(ctx, "closed_days", dayKey, "delete", payload)
}
// LogClosedWeek appends a closed_week upsert to the sync log.
func (s *SyncStore) LogClosedWeek(ctx context.Context, w *domain.ClosedWeek) error {
payload, err := json.Marshal(w)
@@ -159,6 +165,12 @@ func (s *SyncStore) LogClosedWeek(ctx context.Context, w *domain.ClosedWeek) err
return s.log(ctx, "closed_weeks", w.WeekKey, "upsert", string(payload))
}
// LogClosedWeekDelete appends a closed_week delete to the sync log.
func (s *SyncStore) LogClosedWeekDelete(ctx context.Context, weekKey string) error {
payload := fmt.Sprintf(`{"week_key":%q}`, weekKey)
return s.log(ctx, "closed_weeks", weekKey, "delete", payload)
}
// LogSettings appends a settings upsert to the sync log.
func (s *SyncStore) LogSettings(ctx context.Context, set *domain.Settings) error {
payload, err := json.Marshal(set)