mirror of
https://github.com/aljazceru/ditto.git
synced 2026-01-22 23:04:23 +01:00
Stop recounting author stats constantly
This commit is contained in:
@@ -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<string, true>({ 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(() => {}));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user