diff --git a/deno.json b/deno.json index 2bbc288..48b468e 100644 --- a/deno.json +++ b/deno.json @@ -21,7 +21,6 @@ "@bradenmacdonald/s3-lite-client": "jsr:@bradenmacdonald/s3-lite-client@^0.7.4", "@db/sqlite": "jsr:@db/sqlite@^0.11.1", "@isaacs/ttlcache": "npm:@isaacs/ttlcache@^1.4.1", - "@lambdalisue/async": "jsr:@lambdalisue/async@^2.1.1", "@noble/secp256k1": "npm:@noble/secp256k1@^2.0.0", "@nostrify/nostrify": "jsr:@nostrify/nostrify@^0.22.4", "@sentry/deno": "https://deno.land/x/sentry@7.112.2/index.mjs", diff --git a/src/storages/hydrate.ts b/src/storages/hydrate.ts index c7c8bb3..2cadc7e 100644 --- a/src/storages/hydrate.ts +++ b/src/storages/hydrate.ts @@ -5,8 +5,6 @@ import { DittoDB } from '@/db/DittoDB.ts'; import { DittoTables } from '@/db/DittoTables.ts'; import { Conf } from '@/config.ts'; import { type DittoEvent } from '@/interfaces/DittoEvent.ts'; -import { Storages } from '@/storages.ts'; -import { refreshAuthorStatsDebounced } from '@/utils/stats.ts'; import { findQuoteTag } from '@/utils/tags.ts'; interface HydrateOpts { @@ -58,8 +56,6 @@ async function hydrateEvents(opts: HydrateOpts): Promise { events: await gatherEventStats(cache), }; - refreshMissingAuthorStats(events, stats.authors); - // Dedupe events. const results = [...new Map(cache.map((event) => [event.id, event])).values()]; @@ -276,25 +272,6 @@ async function gatherAuthorStats(events: DittoEvent[]): Promise( - events - .filter((event) => event.kind === 0) - .map((event) => event.pubkey), - ); - - const missing = pubkeys.difference( - new Set(stats.map((stat) => stat.pubkey)), - ); - - for (const pubkey of missing) { - refreshAuthorStatsDebounced({ pubkey, store, kysely }); - } -} - /** Collect event stats from the events. */ async function gatherEventStats(events: DittoEvent[]): Promise { const ids = new Set( diff --git a/src/utils/stats.ts b/src/utils/stats.ts index 0b0eb7e..62135c0 100644 --- a/src/utils/stats.ts +++ b/src/utils/stats.ts @@ -1,7 +1,5 @@ -import { Semaphore } from '@lambdalisue/async'; import { NostrEvent, NStore } from '@nostrify/nostrify'; import { Kysely, UpdateObject } from 'kysely'; -import { LRUCache } from 'lru-cache'; import { SetRequired } from 'type-fest'; import { DittoTables } from '@/db/DittoTables.ts'; @@ -266,18 +264,3 @@ export async function refreshAuthorStats( return stats; } - -const authorStatsSemaphore = new Semaphore(10); -const refreshedAuthors = new LRUCache({ max: 1000 }); - -/** Calls `refreshAuthorStats` only once per author. */ -export function refreshAuthorStatsDebounced(opts: RefreshAuthorStatsOpts): void { - if (refreshedAuthors.get(opts.pubkey)) { - return; - } - - refreshedAuthors.set(opts.pubkey, true); - - authorStatsSemaphore - .lock(() => refreshAuthorStats(opts).catch(() => {})); -}