MCPcopy Create free account
hub / github.com/adcontextprotocol/adcp / main

Function main

scripts/regen-illustrations.ts:17–39  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

15];
16
17async function main() {
18 for (const id of IDS) {
19 const { rows } = await pool.query('SELECT title, category, excerpt FROM perspectives WHERE id = $1', [id]);
20 if (!rows[0]) { console.log(`SKIP ${id} - not found`); continue; }
21 const { title, category, excerpt } = rows[0];
22 console.log(`Generating: ${title.slice(0, 60)}...`);
23 try {
24 const { imageBuffer, promptUsed } = await generateIllustration({ title, category, excerpt });
25 const hex = '\\x' + imageBuffer.toString('hex');
26 const ins = await pool.query(
27 `INSERT INTO perspective_illustrations (perspective_id, image_data, prompt_used, status, approved_at)
28 VALUES ($1, $2, $3, 'approved', NOW()) RETURNING id`,
29 [id, hex, promptUsed]
30 );
31 const illId = ins.rows[0].id;
32 await pool.query('UPDATE perspectives SET illustration_id = $1 WHERE id = $2', [illId, id]);
33 console.log(` OK: ${illId} (${(imageBuffer.length / 1024).toFixed(0)} KB)`);
34 } catch (e: any) {
35 console.log(` FAIL: ${e.message}`);
36 }
37 }
38 await pool.end();
39}
40main();

Callers 1

Calls 2

generateIllustrationFunction · 0.85
queryMethod · 0.80

Tested by

no test coverage detected