From a6cee985e9e09a512a5bbd0a6ee4535bcff1b246 Mon Sep 17 00:00:00 2001 From: Frank <83515+fwang@users.noreply.github.com> Date: Sun, 9 Aug 2026 14:39:14 +0000 Subject: [PATCH] refactor(stats): fall through to partial sync --- packages/stats/server/src/stat-sync.ts | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/packages/stats/server/src/stat-sync.ts b/packages/stats/server/src/stat-sync.ts index 62dba90fbef..613fbec5b7d 100644 --- a/packages/stats/server/src/stat-sync.ts +++ b/packages/stats/server/src/stat-sync.ts @@ -19,18 +19,19 @@ const daemon = Effect.gen(function* () { let lastFullDay = "" const pass = Effect.gen(function* () { const today = new Date().toISOString().slice(0, 10) - if (lastFullDay === today) return yield* syncStats({ full: false }) - - const completed = yield* syncStats({ full: true }).pipe( - Effect.as(true), - Effect.catchCause((cause) => - Effect.logWarning(`full stats sync failed; falling back to incremental sync ${Cause.pretty(cause)}`).pipe( - Effect.as(false), + if (lastFullDay !== today) { + const completed = yield* syncStats({ full: true }).pipe( + Effect.as(true), + Effect.catchCause((cause) => + Effect.logWarning(`full stats sync failed; falling back to incremental sync ${Cause.pretty(cause)}`).pipe( + Effect.as(false), + ), ), - ), - ) - if (!completed) yield* syncStats({ full: false }) - lastFullDay = today + ) + lastFullDay = today + if (completed) return + } + yield* syncStats({ full: false }) }).pipe( Effect.catchCause((cause) => Effect.logWarning(`stats sync failed ${JSON.stringify({ cause: Cause.pretty(cause) })}`),