mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 11:29:46 +00:00
refactor(populate search script): use store.req instead of streaming
This commit is contained in:
parent
b3e56320a0
commit
197b2c8c8b
1 changed files with 12 additions and 12 deletions
|
|
@ -2,23 +2,23 @@ import { NSchema as n } from '@nostrify/nostrify';
|
||||||
import { Storages } from '@/storages.ts';
|
import { Storages } from '@/storages.ts';
|
||||||
import { DittoTables } from '@/db/DittoTables.ts';
|
import { DittoTables } from '@/db/DittoTables.ts';
|
||||||
|
|
||||||
|
const store = await Storages.db();
|
||||||
const kysely = await Storages.kysely();
|
const kysely = await Storages.kysely();
|
||||||
const stream = kysely
|
|
||||||
.selectFrom('nostr_events')
|
|
||||||
.select(['pubkey', 'content'])
|
|
||||||
.where('kind', '=', 0)
|
|
||||||
.stream();
|
|
||||||
|
|
||||||
const values: DittoTables['author_search'][] = [];
|
const values: DittoTables['author_search'][] = [];
|
||||||
|
|
||||||
for await (const author of stream) {
|
for await (const msg of store.req([{ kinds: [0] }])) {
|
||||||
const { name, nip05 } = n.json().pipe(n.metadata()).catch({}).parse(author.content);
|
if (msg[0] === 'EVENT') {
|
||||||
const search = [name, nip05].filter(Boolean).join(' ').trim();
|
const { pubkey, content } = msg[2];
|
||||||
|
|
||||||
values.push({
|
const { name, nip05 } = n.json().pipe(n.metadata()).catch({}).parse(content);
|
||||||
pubkey: author.pubkey,
|
const search = [name, nip05].filter(Boolean).join(' ').trim();
|
||||||
search,
|
|
||||||
});
|
values.push({
|
||||||
|
pubkey: pubkey,
|
||||||
|
search,
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue