()
| 43 | ]; |
| 44 | |
| 45 | async function main() { |
| 46 | const dbConfig = getDatabaseConfig(); |
| 47 | if (!dbConfig) throw new Error('No DB config'); |
| 48 | await initializeDatabase(dbConfig); |
| 49 | const { getPool } = await import('../server/src/db/client.js'); |
| 50 | const pool = getPool(); |
| 51 | |
| 52 | for (const p of PERSPECTIVES) { |
| 53 | // Clear old illustration |
| 54 | await pool.query('UPDATE perspectives SET illustration_id = NULL WHERE id = $1', [p.id]); |
| 55 | await pool.query('DELETE FROM perspective_illustrations WHERE perspective_id = $1', [p.id]); |
| 56 | |
| 57 | console.log(`\nGenerating: ${p.title.slice(0, 60)}...`); |
| 58 | const { imageBuffer, promptUsed } = await generateIllustration({ |
| 59 | title: p.title, |
| 60 | category: p.category, |
| 61 | authorDescription: p.authorDescription, |
| 62 | }); |
| 63 | console.log('Generated', (imageBuffer.length / 1024).toFixed(0), 'KB'); |
| 64 | |
| 65 | const illustration = await db.createIllustration({ |
| 66 | perspective_id: p.id, |
| 67 | image_data: imageBuffer, |
| 68 | prompt_used: promptUsed, |
| 69 | author_description: p.authorDescription, |
| 70 | status: 'generated', |
| 71 | }); |
| 72 | |
| 73 | await db.approveIllustration(illustration.id, p.id); |
| 74 | console.log('Approved:', illustration.id); |
| 75 | } |
| 76 | |
| 77 | console.log('\nDone!'); |
| 78 | process.exit(0); |
| 79 | } |
| 80 | main().catch(e => { console.error(e); process.exit(1); }); |
no test coverage detected