mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-10 05:12:14 +00:00
chore(drain): per-user COMPLETE log line for the cumulative drain
drainPerSampleCumulative emitted a [drain] START line per user but nothing on completion — an operator scanning the worker log had to infer per-user finish times from the next user's START line. Add a per-user COMPLETE line that carries the bucketsCollapsed / perSampleRowsDeleted / dailyRowsUpserted deltas the user contributed so START / COMPLETE pair cleanly in the worker log.
This commit is contained in:
1 parent
f2f1e5f036
commit
bf1b7b1604
1 file changed
+23
@@ -310,6 +310,13 @@ export async function drainPerSampleCumulative(
|
||||
const tz = user.timezone && user.timezone.length > 0 ? user.timezone : "Europe/Berlin";
|
||||
log(`[drain] user=${user.id} tz=${tz}${dryRun ? " (dry-run)" : ""}`);
|
||||
|
||||
// v1.4.38 — per-user counters that mirror the existing aggregate
|
||||
// totals. Lets the per-user COMPLETE log line carry useful
|
||||
// numbers without re-walking the summary list later.
|
||||
const beforeBucketsCollapsed = summary.totals.bucketsCollapsed;
|
||||
const beforePerSampleDeleted = summary.totals.perSampleRowsDeleted;
|
||||
const beforeDailyUpserted = summary.totals.dailyRowsUpserted;
|
||||
|
||||
for (const type of CUMULATIVE_HK_TYPES) {
|
||||
const hkIdentifier = hkIdentifierForType(type);
|
||||
if (!hkIdentifier) continue;
|
||||
@@ -417,6 +424,22 @@ export async function drainPerSampleCumulative(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// v1.4.38 — per-user COMPLETE log line. Mirrors the START line on
|
||||
// line 311 so an operator scanning the worker log can pair
|
||||
// "drain started for user X" with "drain finished for user X"
|
||||
// without scrolling through every per-type bucket. Counts are
|
||||
// computed as the delta against the snapshot taken before the
|
||||
// per-type loop started.
|
||||
const userBucketsCollapsed =
|
||||
summary.totals.bucketsCollapsed - beforeBucketsCollapsed;
|
||||
const userPerSampleDeleted =
|
||||
summary.totals.perSampleRowsDeleted - beforePerSampleDeleted;
|
||||
const userDailyUpserted =
|
||||
summary.totals.dailyRowsUpserted - beforeDailyUpserted;
|
||||
log(
|
||||
`[drain] user=${user.id} complete bucketsCollapsed=${userBucketsCollapsed} perSampleRowsDeleted=${userPerSampleDeleted} dailyRowsUpserted=${userDailyUpserted}${dryRun ? " (dry-run)" : ""}`,
|
||||
);
|
||||
}
|
||||
|
||||
log(
|
||||
|
||||
Reference in new issue
Block a user