mirror of
https://github.com/anomalyco/opencode.git
synced 2026-08-10 03:19:59 -04:00
refactor(stats): fall through to partial sync
This commit is contained in:
@@ -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) })}`),
|
||||
|
||||
Reference in New Issue
Block a user