ditto/scripts/stats-recompute.ts
2024-09-11 13:23:06 -05:00

22 lines
508 B
TypeScript

import { nip19 } from 'nostr-tools';
import { Storages } from '@/storages.ts';
import { refreshAuthorStats } from '@/utils/stats.ts';
let pubkey: string;
try {
const result = nip19.decode(Deno.args[0]);
if (result.type === 'npub') {
pubkey = result.data;
} else {
throw new Error('Invalid npub');
}
} catch {
console.error('Invalid npub');
Deno.exit(1);
}
const store = await Storages.db();
const kysely = await Storages.kysely();
await refreshAuthorStats({ pubkey, kysely, store });