From 4ecc9c75b9ecacfcabf39af03671966733da1153 Mon Sep 17 00:00:00 2001 From: "P. Reis" Date: Thu, 18 Apr 2024 10:34:12 -0300 Subject: [PATCH] draft: proof of concept InsertQueryBuilder async error --- src/stats.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/stats.ts b/src/stats.ts index 69182e8e..c0b1002c 100644 --- a/src/stats.ts +++ b/src/stats.ts @@ -21,10 +21,14 @@ async function updateStats(event: NostrEvent) { if (event.kind === 3) { prev = await maybeGetPrev(event); if (!prev || event.created_at >= prev.created_at) { - queries.push(updateFollowingCountQuery(event)); + try { + queries.push(await updateFollowingCountQuery(event)); // We know updateFollowingCountQuery always worked, see what happens after we make it an async function + } catch (e) { + console.log('ERROR', e); + } - const followersQuery = await updateFollowersCountQuery(event); - if (followersQuery) queries.push(followersQuery); + //const followersQuery = await updateFollowersCountQuery(event); + //if (followersQuery) queries.push(followersQuery); } } @@ -161,7 +165,9 @@ async function maybeGetPrev(event: NostrEvent): Promise { } /** Set the following count to the total number of unique "p" tags in the follow list. */ -function updateFollowingCountQuery({ pubkey, tags }: NostrEvent) { +async function updateFollowingCountQuery({ pubkey, tags }: NostrEvent) { + await eventsDB.query([{ kinds: [0] }]); + const following_count = new Set( tags .filter(([name]) => name === 'p')