From 251500fba1b82de21098776c4d98bfd0d6a40660 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Fri, 17 May 2024 11:39:21 -0500 Subject: [PATCH] Never let stats be less than 0 --- src/storages/hydrate.ts | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/storages/hydrate.ts b/src/storages/hydrate.ts index 8d2d302..9b95841 100644 --- a/src/storages/hydrate.ts +++ b/src/storages/hydrate.ts @@ -251,11 +251,19 @@ async function gatherAuthorStats(events: DittoEvent[]): Promise ({ + pubkey: row.pubkey, + followers_count: Math.max(0, row.followers_count), + following_count: Math.max(0, row.following_count), + notes_count: Math.max(0, row.notes_count), + })); } /** Collect event stats from the events. */ @@ -271,11 +279,19 @@ async function gatherEventStats(events: DittoEvent[]): Promise ({ + event_id: row.event_id, + reposts_count: Math.max(0, row.reposts_count), + reactions_count: Math.max(0, row.reactions_count), + replies_count: Math.max(0, row.replies_count), + })); } /** Return a normalized event without any non-standard keys. */