Merge branch 'add-script-populate-gallery' into 'main'

feat: populate extensions

See merge request soapbox-pub/ditto!634
This commit is contained in:
P. Reis 2025-02-03 23:07:13 +00:00
commit be116d64d9
2 changed files with 27 additions and 0 deletions

View file

@ -22,6 +22,7 @@
"trends": "deno run -A --env-file --deny-read=.env scripts/trends.ts",
"clean:deps": "deno cache --reload src/app.ts",
"db:populate-search": "deno run -A --env-file --deny-read=.env scripts/db-populate-search.ts",
"db:populate-extensions": "deno run -A --env-file --deny-read=.env scripts/db-populate-extensions.ts",
"vapid": "deno run scripts/vapid.ts"
},
"unstable": [

View file

@ -0,0 +1,26 @@
import { Storages } from '@/storages.ts';
import { EventsDB } from '@/storages/EventsDB.ts';
const store = await Storages.db();
const kysely = await Storages.kysely();
for await (const msg of store.req([{}])) {
if (msg[0] === 'EVENT') {
const event = msg[2];
const ext = EventsDB.indexExtensions(event);
try {
await kysely.updateTable('nostr_events')
.set('search_ext', ext)
.where('id', '=', event.id)
.execute();
} catch {
// do nothing
}
} else {
break;
}
}
Deno.exit();