mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 03:19:46 +00:00
Remove storages.ts from scripts
This commit is contained in:
parent
63c0f8b032
commit
ca5c887705
13 changed files with 114 additions and 66 deletions
|
|
@ -1,13 +1,17 @@
|
||||||
|
import { DittoConf } from '@ditto/conf';
|
||||||
|
import { DittoPolyPg } from '@ditto/db';
|
||||||
import { JsonParseStream } from '@std/json/json-parse-stream';
|
import { JsonParseStream } from '@std/json/json-parse-stream';
|
||||||
import { TextLineStream } from '@std/streams/text-line-stream';
|
import { TextLineStream } from '@std/streams/text-line-stream';
|
||||||
|
|
||||||
import { Conf } from '../packages/ditto/config.ts';
|
import { DittoPgStore } from '../packages/ditto/storages/DittoPgStore.ts';
|
||||||
import { Storages } from '../packages/ditto/storages.ts';
|
|
||||||
import { type EventStub } from '../packages/ditto/utils/api.ts';
|
import { type EventStub } from '../packages/ditto/utils/api.ts';
|
||||||
import { nostrNow } from '../packages/ditto/utils.ts';
|
import { nostrNow } from '../packages/ditto/utils.ts';
|
||||||
|
|
||||||
const signer = Conf.signer;
|
const conf = new DittoConf(Deno.env);
|
||||||
const store = await Storages.db();
|
const db = new DittoPolyPg(conf.databaseUrl);
|
||||||
|
const relay = new DittoPgStore({ db, pubkey: await conf.signer.getPublicKey() });
|
||||||
|
|
||||||
|
const { signer } = conf;
|
||||||
|
|
||||||
const readable = Deno.stdin.readable
|
const readable = Deno.stdin.readable
|
||||||
.pipeThrough(new TextDecoderStream())
|
.pipeThrough(new TextDecoderStream())
|
||||||
|
|
@ -22,7 +26,7 @@ for await (const t of readable) {
|
||||||
...t as EventStub,
|
...t as EventStub,
|
||||||
});
|
});
|
||||||
|
|
||||||
await store.event(event);
|
await relay.event(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
Deno.exit(0);
|
Deno.exit(0);
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,20 @@
|
||||||
|
import { DittoConf } from '@ditto/conf';
|
||||||
|
import { DittoPolyPg } from '@ditto/db';
|
||||||
import { NSchema } from '@nostrify/nostrify';
|
import { NSchema } from '@nostrify/nostrify';
|
||||||
import { nip19 } from 'nostr-tools';
|
import { nip19 } from 'nostr-tools';
|
||||||
|
|
||||||
import { Conf } from '../packages/ditto/config.ts';
|
import { DittoPgStore } from '../packages/ditto/storages/DittoPgStore.ts';
|
||||||
import { Storages } from '../packages/ditto/storages.ts';
|
|
||||||
import { nostrNow } from '../packages/ditto/utils.ts';
|
import { nostrNow } from '../packages/ditto/utils.ts';
|
||||||
|
|
||||||
const store = await Storages.db();
|
const conf = new DittoConf(Deno.env);
|
||||||
|
const db = new DittoPolyPg(conf.databaseUrl);
|
||||||
|
const relay = new DittoPgStore({ db, pubkey: await conf.signer.getPublicKey() });
|
||||||
|
|
||||||
const [pubkeyOrNpub, role] = Deno.args;
|
const [pubkeyOrNpub, role] = Deno.args;
|
||||||
const pubkey = pubkeyOrNpub.startsWith('npub1') ? nip19.decode(pubkeyOrNpub as `npub1${string}`).data : pubkeyOrNpub;
|
const pubkey = pubkeyOrNpub.startsWith('npub1') ? nip19.decode(pubkeyOrNpub as `npub1${string}`).data : pubkeyOrNpub;
|
||||||
|
|
||||||
|
const { signer } = conf;
|
||||||
|
|
||||||
if (!NSchema.id().safeParse(pubkey).success) {
|
if (!NSchema.id().safeParse(pubkey).success) {
|
||||||
console.error('Invalid pubkey');
|
console.error('Invalid pubkey');
|
||||||
Deno.exit(1);
|
Deno.exit(1);
|
||||||
|
|
@ -20,10 +25,9 @@ if (!['admin', 'user'].includes(role)) {
|
||||||
Deno.exit(1);
|
Deno.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
const signer = Conf.signer;
|
|
||||||
const admin = await signer.getPublicKey();
|
const admin = await signer.getPublicKey();
|
||||||
|
|
||||||
const [existing] = await store.query([{
|
const [existing] = await relay.query([{
|
||||||
kinds: [30382],
|
kinds: [30382],
|
||||||
authors: [admin],
|
authors: [admin],
|
||||||
'#d': [pubkey],
|
'#d': [pubkey],
|
||||||
|
|
@ -57,6 +61,6 @@ const event = await signer.signEvent({
|
||||||
created_at: nostrNow(),
|
created_at: nostrNow(),
|
||||||
});
|
});
|
||||||
|
|
||||||
await store.event(event);
|
await relay.event(event);
|
||||||
|
|
||||||
Deno.exit(0);
|
Deno.exit(0);
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,13 @@
|
||||||
|
import { DittoConf } from '@ditto/conf';
|
||||||
|
import { DittoPolyPg } from '@ditto/db';
|
||||||
import { NostrFilter } from '@nostrify/nostrify';
|
import { NostrFilter } from '@nostrify/nostrify';
|
||||||
import { Command, InvalidOptionArgumentError } from 'commander';
|
import { Command, InvalidOptionArgumentError } from 'commander';
|
||||||
|
|
||||||
import { Storages } from '../packages/ditto/storages.ts';
|
import { DittoPgStore } from '../packages/ditto/storages/DittoPgStore.ts';
|
||||||
|
|
||||||
|
const conf = new DittoConf(Deno.env);
|
||||||
|
const db = new DittoPolyPg(conf.databaseUrl);
|
||||||
|
const relay = new DittoPgStore({ db, pubkey: await conf.signer.getPublicKey() });
|
||||||
|
|
||||||
interface ExportFilter {
|
interface ExportFilter {
|
||||||
authors?: string[];
|
authors?: string[];
|
||||||
|
|
@ -98,8 +104,6 @@ export function buildFilter(args: ExportFilter) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function exportEvents(args: ExportFilter) {
|
async function exportEvents(args: ExportFilter) {
|
||||||
const store = await Storages.db();
|
|
||||||
|
|
||||||
let filter: NostrFilter = {};
|
let filter: NostrFilter = {};
|
||||||
try {
|
try {
|
||||||
filter = buildFilter(args);
|
filter = buildFilter(args);
|
||||||
|
|
@ -108,7 +112,7 @@ async function exportEvents(args: ExportFilter) {
|
||||||
}
|
}
|
||||||
|
|
||||||
let count = 0;
|
let count = 0;
|
||||||
for await (const msg of store.req([filter])) {
|
for await (const msg of relay.req([filter])) {
|
||||||
if (msg[0] === 'EOSE') {
|
if (msg[0] === 'EOSE') {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,16 @@
|
||||||
import { Semaphore } from '@core/asyncutil';
|
import { Semaphore } from '@core/asyncutil';
|
||||||
|
import { DittoConf } from '@ditto/conf';
|
||||||
|
import { DittoPolyPg } from '@ditto/db';
|
||||||
import { NostrEvent } from '@nostrify/nostrify';
|
import { NostrEvent } from '@nostrify/nostrify';
|
||||||
import { JsonParseStream } from '@std/json/json-parse-stream';
|
import { JsonParseStream } from '@std/json/json-parse-stream';
|
||||||
import { TextLineStream } from '@std/streams/text-line-stream';
|
import { TextLineStream } from '@std/streams/text-line-stream';
|
||||||
|
|
||||||
import { Conf } from '../packages/ditto/config.ts';
|
import { DittoPgStore } from '../packages/ditto/storages/DittoPgStore.ts';
|
||||||
import { Storages } from '../packages/ditto/storages.ts';
|
|
||||||
|
|
||||||
const store = await Storages.db();
|
const conf = new DittoConf(Deno.env);
|
||||||
const sem = new Semaphore(Conf.pg.poolSize);
|
const db = new DittoPolyPg(conf.databaseUrl);
|
||||||
|
const relay = new DittoPgStore({ db, pubkey: await conf.signer.getPublicKey() });
|
||||||
|
const sem = new Semaphore(conf.pg.poolSize);
|
||||||
|
|
||||||
console.warn('Importing events...');
|
console.warn('Importing events...');
|
||||||
|
|
||||||
|
|
@ -27,7 +30,7 @@ for await (const line of readable) {
|
||||||
|
|
||||||
sem.lock(async () => {
|
sem.lock(async () => {
|
||||||
try {
|
try {
|
||||||
await store.event(event);
|
await relay.event(event);
|
||||||
console.warn(`(${count}) Event<${event.kind}> ${event.id}`);
|
console.warn(`(${count}) Event<${event.kind}> ${event.id}`);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error instanceof Error && error.message.includes('violates unique constraint')) {
|
if (error instanceof Error && error.message.includes('violates unique constraint')) {
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
import { Storages } from '../packages/ditto/storages.ts';
|
import { DittoConf } from '@ditto/conf';
|
||||||
|
import { DittoPolyPg } from '@ditto/db';
|
||||||
|
|
||||||
// This migrates kysely internally.
|
const conf = new DittoConf(Deno.env);
|
||||||
const kysely = await Storages.kysely();
|
await using db = new DittoPolyPg(conf.databaseUrl);
|
||||||
|
|
||||||
// Close the connection before exiting.
|
await db.migrate();
|
||||||
await kysely.destroy();
|
|
||||||
|
|
||||||
Deno.exit();
|
Deno.exit();
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,22 @@
|
||||||
import { policyWorker } from '../packages/ditto/workers/policy.ts';
|
import { DittoConf } from '@ditto/conf';
|
||||||
import { Storages } from '../packages/ditto/storages.ts';
|
import { DittoPolyPg } from '@ditto/db';
|
||||||
|
|
||||||
|
import { DittoPgStore } from '../packages/ditto/storages/DittoPgStore.ts';
|
||||||
|
import { policyWorker } from '../packages/ditto/workers/policy.ts';
|
||||||
|
|
||||||
|
const conf = new DittoConf(Deno.env);
|
||||||
|
const db = new DittoPolyPg(conf.databaseUrl);
|
||||||
|
const relay = new DittoPgStore({ db, pubkey: await conf.signer.getPublicKey() });
|
||||||
|
|
||||||
const db = await Storages.db();
|
|
||||||
let count = 0;
|
let count = 0;
|
||||||
|
|
||||||
for await (const msg of db.req([{}])) {
|
for await (const msg of relay.req([{}])) {
|
||||||
const [type, , event] = msg;
|
const [type, , event] = msg;
|
||||||
if (type === 'EOSE') console.log('EOSE');
|
if (type === 'EOSE') console.log('EOSE');
|
||||||
if (type !== 'EVENT') continue;
|
if (type !== 'EVENT') continue;
|
||||||
const [, , ok] = await policyWorker.call(event, AbortSignal.timeout(5000));
|
const [, , ok] = await policyWorker.call(event, AbortSignal.timeout(5000));
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
await db.remove([{ ids: [event.id] }]);
|
await relay.remove([{ ids: [event.id] }]);
|
||||||
count += 1;
|
count += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,13 @@
|
||||||
|
import { DittoConf } from '@ditto/conf';
|
||||||
|
import { DittoPolyPg } from '@ditto/db';
|
||||||
import { NostrEvent } from '@nostrify/nostrify';
|
import { NostrEvent } from '@nostrify/nostrify';
|
||||||
|
|
||||||
import { Storages } from '../packages/ditto/storages.ts';
|
|
||||||
import { DittoPgStore } from '../packages/ditto/storages/DittoPgStore.ts';
|
import { DittoPgStore } from '../packages/ditto/storages/DittoPgStore.ts';
|
||||||
|
|
||||||
const kysely = await Storages.kysely();
|
const conf = new DittoConf(Deno.env);
|
||||||
|
const db = new DittoPolyPg(conf.databaseUrl);
|
||||||
|
|
||||||
const query = kysely
|
const query = db.kysely
|
||||||
.selectFrom('nostr_events')
|
.selectFrom('nostr_events')
|
||||||
.select(['id', 'kind', 'content', 'pubkey', 'tags', 'created_at', 'sig']);
|
.select(['id', 'kind', 'content', 'pubkey', 'tags', 'created_at', 'sig']);
|
||||||
|
|
||||||
|
|
@ -14,7 +16,7 @@ for await (const row of query.stream()) {
|
||||||
const ext = DittoPgStore.indexExtensions(event);
|
const ext = DittoPgStore.indexExtensions(event);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await kysely
|
await db.kysely
|
||||||
.updateTable('nostr_events')
|
.updateTable('nostr_events')
|
||||||
.set('search_ext', ext)
|
.set('search_ext', ext)
|
||||||
.where('id', '=', event.id)
|
.where('id', '=', event.id)
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,22 @@
|
||||||
import { Semaphore } from '@core/asyncutil';
|
import { Semaphore } from '@core/asyncutil';
|
||||||
import { NostrEvent } from '@nostrify/nostrify';
|
import { NostrEvent } from '@nostrify/nostrify';
|
||||||
|
import { MockRelay } from '@nostrify/nostrify/test';
|
||||||
|
|
||||||
import { updateAuthorData } from '../packages/ditto/pipeline.ts';
|
import { DittoConf } from '@ditto/conf';
|
||||||
import { Storages } from '../packages/ditto/storages.ts';
|
import { DittoPolyPg } from '@ditto/db';
|
||||||
|
|
||||||
|
import { DittoAPIStore } from '../packages/ditto/storages/DittoAPIStore.ts';
|
||||||
|
import { DittoPgStore } from '../packages/ditto/storages/DittoPgStore.ts';
|
||||||
|
|
||||||
|
const conf = new DittoConf(Deno.env);
|
||||||
|
const db = new DittoPolyPg(conf.databaseUrl);
|
||||||
|
|
||||||
|
const pgstore = new DittoPgStore({ db, pubkey: await conf.signer.getPublicKey() });
|
||||||
|
const apistore = new DittoAPIStore({ conf, db, relay: pgstore, pool: new MockRelay() });
|
||||||
|
|
||||||
const kysely = await Storages.kysely();
|
|
||||||
const sem = new Semaphore(5);
|
const sem = new Semaphore(5);
|
||||||
|
|
||||||
const query = kysely
|
const query = db.kysely
|
||||||
.selectFrom('nostr_events')
|
.selectFrom('nostr_events')
|
||||||
.select(['id', 'kind', 'content', 'pubkey', 'tags', 'created_at', 'sig'])
|
.select(['id', 'kind', 'content', 'pubkey', 'tags', 'created_at', 'sig'])
|
||||||
.where('kind', '=', 0);
|
.where('kind', '=', 0);
|
||||||
|
|
@ -19,7 +28,7 @@ for await (const row of query.stream(100)) {
|
||||||
|
|
||||||
sem.lock(async () => {
|
sem.lock(async () => {
|
||||||
const event: NostrEvent = { ...row, created_at: Number(row.created_at) };
|
const event: NostrEvent = { ...row, created_at: Number(row.created_at) };
|
||||||
await updateAuthorData(event, AbortSignal.timeout(3000));
|
await apistore.updateAuthorData(event, AbortSignal.timeout(3000));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,14 @@
|
||||||
|
import { DittoConf } from '@ditto/conf';
|
||||||
|
import { DittoPolyPg } from '@ditto/db';
|
||||||
import { NSchema as n } from '@nostrify/nostrify';
|
import { NSchema as n } from '@nostrify/nostrify';
|
||||||
|
|
||||||
import { Storages } from '../packages/ditto/storages.ts';
|
import { DittoPgStore } from '../packages/ditto/storages/DittoPgStore.ts';
|
||||||
|
|
||||||
const store = await Storages.db();
|
const conf = new DittoConf(Deno.env);
|
||||||
const kysely = await Storages.kysely();
|
const db = new DittoPolyPg(conf.databaseUrl);
|
||||||
|
const relay = new DittoPgStore({ db, pubkey: await conf.signer.getPublicKey() });
|
||||||
|
|
||||||
for await (const msg of store.req([{ kinds: [0] }])) {
|
for await (const msg of relay.req([{ kinds: [0] }])) {
|
||||||
if (msg[0] === 'EVENT') {
|
if (msg[0] === 'EVENT') {
|
||||||
const { pubkey, content } = msg[2];
|
const { pubkey, content } = msg[2];
|
||||||
|
|
||||||
|
|
@ -13,7 +16,7 @@ for await (const msg of store.req([{ kinds: [0] }])) {
|
||||||
const search = [name, nip05].filter(Boolean).join(' ').trim();
|
const search = [name, nip05].filter(Boolean).join(' ').trim();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await kysely.insertInto('author_stats').values({
|
await db.kysely.insertInto('author_stats').values({
|
||||||
pubkey,
|
pubkey,
|
||||||
search,
|
search,
|
||||||
followers_count: 0,
|
followers_count: 0,
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,14 @@
|
||||||
import { Conf } from '../packages/ditto/config.ts';
|
import { DittoConf } from '@ditto/conf';
|
||||||
import { Storages } from '../packages/ditto/storages.ts';
|
import { DittoPolyPg } from '@ditto/db';
|
||||||
|
|
||||||
const kysely = await Storages.kysely();
|
const conf = new DittoConf(Deno.env);
|
||||||
const statsQuery = kysely.selectFrom('author_stats').select('pubkey');
|
const db = new DittoPolyPg(conf.databaseUrl);
|
||||||
const { streakWindow } = Conf;
|
|
||||||
|
const statsQuery = db.kysely.selectFrom('author_stats').select('pubkey');
|
||||||
|
const { streakWindow } = conf;
|
||||||
|
|
||||||
for await (const { pubkey } of statsQuery.stream(10)) {
|
for await (const { pubkey } of statsQuery.stream(10)) {
|
||||||
const eventsQuery = kysely
|
const eventsQuery = db.kysely
|
||||||
.selectFrom('nostr_events')
|
.selectFrom('nostr_events')
|
||||||
.select('created_at')
|
.select('created_at')
|
||||||
.where('pubkey', '=', pubkey)
|
.where('pubkey', '=', pubkey)
|
||||||
|
|
@ -38,7 +40,7 @@ for await (const { pubkey } of statsQuery.stream(10)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (start && end) {
|
if (start && end) {
|
||||||
await kysely
|
await db.kysely
|
||||||
.updateTable('author_stats')
|
.updateTable('author_stats')
|
||||||
.set({
|
.set({
|
||||||
streak_end: end,
|
streak_end: end,
|
||||||
|
|
|
||||||
|
|
@ -3,12 +3,16 @@
|
||||||
* by looking them up on a list of relays.
|
* by looking them up on a list of relays.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { DittoConf } from '@ditto/conf';
|
||||||
|
import { DittoPolyPg } from '@ditto/db';
|
||||||
import { NostrEvent, NRelay1, NSchema } from '@nostrify/nostrify';
|
import { NostrEvent, NRelay1, NSchema } from '@nostrify/nostrify';
|
||||||
import { nip19 } from 'nostr-tools';
|
import { nip19 } from 'nostr-tools';
|
||||||
|
|
||||||
import { Storages } from '../packages/ditto/storages.ts';
|
import { DittoPgStore } from '../packages/ditto/storages/DittoPgStore.ts';
|
||||||
|
|
||||||
const store = await Storages.db();
|
const conf = new DittoConf(Deno.env);
|
||||||
|
const db = new DittoPolyPg(conf.databaseUrl);
|
||||||
|
const relay = new DittoPgStore({ db, pubkey: await conf.signer.getPublicKey() });
|
||||||
|
|
||||||
interface ImportEventsOpts {
|
interface ImportEventsOpts {
|
||||||
profilesOnly: boolean;
|
profilesOnly: boolean;
|
||||||
|
|
@ -19,7 +23,7 @@ const importUsers = async (
|
||||||
authors: string[],
|
authors: string[],
|
||||||
relays: string[],
|
relays: string[],
|
||||||
opts?: Partial<ImportEventsOpts>,
|
opts?: Partial<ImportEventsOpts>,
|
||||||
doEvent: DoEvent = async (event: NostrEvent) => await store.event(event),
|
doEvent: DoEvent = async (event: NostrEvent) => await relay.event(event),
|
||||||
) => {
|
) => {
|
||||||
// Kind 0s + follow lists.
|
// Kind 0s + follow lists.
|
||||||
const profiles: Record<string, Record<number, NostrEvent>> = {};
|
const profiles: Record<string, Record<number, NostrEvent>> = {};
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,13 @@
|
||||||
|
import { DittoConf } from '@ditto/conf';
|
||||||
|
import { DittoPolyPg } from '@ditto/db';
|
||||||
import { Command } from 'commander';
|
import { Command } from 'commander';
|
||||||
import { NostrEvent } from 'nostr-tools';
|
import { NostrEvent } from 'nostr-tools';
|
||||||
|
|
||||||
import { nostrNow } from '../packages/ditto/utils.ts';
|
import { DittoPgStore } from '../packages/ditto/storages/DittoPgStore.ts';
|
||||||
import { Conf } from '../packages/ditto/config.ts';
|
|
||||||
import { Storages } from '../packages/ditto/storages.ts';
|
const conf = new DittoConf(Deno.env);
|
||||||
|
const db = new DittoPolyPg(conf.databaseUrl);
|
||||||
|
const relay = new DittoPgStore({ db, pubkey: await conf.signer.getPublicKey() });
|
||||||
|
|
||||||
function die(code: number, ...args: unknown[]) {
|
function die(code: number, ...args: unknown[]) {
|
||||||
console.error(...args);
|
console.error(...args);
|
||||||
|
|
@ -33,19 +37,19 @@ if (import.meta.main) {
|
||||||
content.lud16 = lightning;
|
content.lud16 = lightning;
|
||||||
content.name = name;
|
content.name = name;
|
||||||
content.picture = image;
|
content.picture = image;
|
||||||
content.website = Conf.localDomain;
|
content.website = conf.localDomain;
|
||||||
|
|
||||||
const signer = Conf.signer;
|
const signer = conf.signer;
|
||||||
const bare: Omit<NostrEvent, 'id' | 'sig' | 'pubkey'> = {
|
const bare: Omit<NostrEvent, 'id' | 'sig' | 'pubkey'> = {
|
||||||
created_at: nostrNow(),
|
|
||||||
kind: 0,
|
kind: 0,
|
||||||
tags: [],
|
tags: [],
|
||||||
content: JSON.stringify(content),
|
content: JSON.stringify(content),
|
||||||
|
created_at: Math.floor(Date.now() / 1000),
|
||||||
};
|
};
|
||||||
const signed = await signer.signEvent(bare);
|
const signed = await signer.signEvent(bare);
|
||||||
|
|
||||||
console.log({ content, signed });
|
console.log({ content, signed });
|
||||||
await Storages.db().then((store) => store.event(signed));
|
await relay.event(signed);
|
||||||
});
|
});
|
||||||
|
|
||||||
await kind0.parseAsync();
|
await kind0.parseAsync();
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,14 @@
|
||||||
|
import { DittoConf } from '@ditto/conf';
|
||||||
|
import { DittoPolyPg } from '@ditto/db';
|
||||||
import { nip19 } from 'nostr-tools';
|
import { nip19 } from 'nostr-tools';
|
||||||
|
|
||||||
import { Storages } from '../packages/ditto/storages.ts';
|
import { DittoPgStore } from '../packages/ditto/storages/DittoPgStore.ts';
|
||||||
import { refreshAuthorStats } from '../packages/ditto/utils/stats.ts';
|
import { refreshAuthorStats } from '../packages/ditto/utils/stats.ts';
|
||||||
|
|
||||||
|
const conf = new DittoConf(Deno.env);
|
||||||
|
const db = new DittoPolyPg(conf.databaseUrl);
|
||||||
|
const relay = new DittoPgStore({ db, pubkey: await conf.signer.getPublicKey() });
|
||||||
|
|
||||||
let pubkey: string;
|
let pubkey: string;
|
||||||
try {
|
try {
|
||||||
const result = nip19.decode(Deno.args[0]);
|
const result = nip19.decode(Deno.args[0]);
|
||||||
|
|
@ -16,7 +22,4 @@ try {
|
||||||
Deno.exit(1);
|
Deno.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
const store = await Storages.db();
|
await refreshAuthorStats({ pubkey, kysely: db.kysely, store: relay });
|
||||||
const kysely = await Storages.kysely();
|
|
||||||
|
|
||||||
await refreshAuthorStats({ pubkey, kysely, store });
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue