From 30559ba043821ac3b6f474964008245bcdfe9418 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Thu, 6 Feb 2025 16:04:25 -0600 Subject: [PATCH] streak-recompute: only update changed rows --- scripts/db-streak-recompute.ts | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/scripts/db-streak-recompute.ts b/scripts/db-streak-recompute.ts index 262f0427..e202baa5 100644 --- a/scripts/db-streak-recompute.ts +++ b/scripts/db-streak-recompute.ts @@ -35,14 +35,16 @@ for await (const { pubkey } of statsQuery.stream(10)) { start = createdAt; } - await kysely - .updateTable('author_stats') - .set({ - streak_end: end, - streak_start: start, - }) - .where('pubkey', '=', pubkey) - .execute(); + if (start && end) { + await kysely + .updateTable('author_stats') + .set({ + streak_end: end, + streak_start: start, + }) + .where('pubkey', '=', pubkey) + .execute(); + } } Deno.exit();