draft: proof of concept InsertQueryBuilder async error

This commit is contained in:
P. Reis 2024-04-18 10:34:12 -03:00
parent c43df106d8
commit 4ecc9c75b9

View file

@ -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<NostrEvent> {
}
/** 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')