refactor: remove automatic background incremental sync
Garmin's rate-limiting means every unattended sync attempt risks a ban; syncing should only ever happen when explicitly triggered via "Sync now" (POST /api/sync/run), never on an unattended timer. Removes the periodic background loop (main.go's runIncrementalSyncLoop, api.Server.RunIncrementalSyncForAllUsers), its GENIUSRUN_INCREMENTAL_SYNC_EVERY config, and store.DB.ListUsers (which existed solely to feed it). The manual "Sync now" flow (Backfill/IncrementalSync/FillPendingDetails via FullSync) is untouched.
This commit is contained in:
@@ -264,31 +264,6 @@ func (s *Server) removeGarminClient(userID int64) {
|
||||
}
|
||||
}
|
||||
|
||||
// RunIncrementalSyncForAllUsers is called on a timer (see main.go) to sync
|
||||
// every provisioned user in turn, replacing the old single-global-Service
|
||||
// background loop.
|
||||
func (s *Server) RunIncrementalSyncForAllUsers(ctx context.Context) {
|
||||
users, err := s.DB.ListUsers(ctx)
|
||||
if err != nil {
|
||||
log.Printf("api: list users for incremental sync: %v", err)
|
||||
return
|
||||
}
|
||||
for _, u := range users {
|
||||
svc, err := s.syncFor(ctx, u.ID)
|
||||
if err != nil {
|
||||
log.Printf("api: sync service for user %d: %v", u.ID, err)
|
||||
continue
|
||||
}
|
||||
if err := svc.IncrementalSync(ctx); err != nil {
|
||||
log.Printf("api: incremental sync for user %d: %v", u.ID, err)
|
||||
continue
|
||||
}
|
||||
if err := svc.FillPendingDetails(ctx, 50); err != nil {
|
||||
log.Printf("api: fill pending details for user %d: %v", u.ID, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var requestIDCounter atomic.Int64
|
||||
|
||||
// requestLoggingMiddleware logs one JSON line per HTTP request (method,
|
||||
|
||||
Reference in New Issue
Block a user