- Add new database migrations for analysis data and job tracking - Implement enhanced document processing service with LLM integration - Add processing progress and queue status components - Create testing guides and utility scripts for CIM processing - Update frontend components for better user experience - Add environment configuration and backup files - Implement job queue service and upload progress tracking
58 lines
1.7 KiB
JavaScript
58 lines
1.7 KiB
JavaScript
const { Pool } = require('pg');
|
||
const { jobQueueService } = require('./src/services/jobQueueService');
|
||
|
||
const pool = new Pool({
|
||
connectionString: 'postgresql://postgres:password@localhost:5432/cim_processor'
|
||
});
|
||
|
||
async function startProcessing() {
|
||
try {
|
||
console.log('🔍 Finding uploaded STAX CIM document...');
|
||
|
||
// Find the STAX CIM document
|
||
const result = await pool.query(`
|
||
SELECT id, original_file_name, status, user_id
|
||
FROM documents
|
||
WHERE original_file_name = 'stax-cim-test.pdf'
|
||
ORDER BY created_at DESC
|
||
LIMIT 1
|
||
`);
|
||
|
||
if (result.rows.length === 0) {
|
||
console.log('❌ No STAX CIM document found');
|
||
return;
|
||
}
|
||
|
||
const document = result.rows[0];
|
||
console.log(`📄 Found document: ${document.original_file_name} (${document.status})`);
|
||
|
||
if (document.status === 'uploaded') {
|
||
console.log('🚀 Starting document processing...');
|
||
|
||
// Start the processing job
|
||
const jobId = await jobQueueService.addJob('document_processing', {
|
||
documentId: document.id,
|
||
userId: document.user_id,
|
||
options: {
|
||
extractText: true,
|
||
generateSummary: true,
|
||
performAnalysis: true,
|
||
},
|
||
}, 0, 3);
|
||
|
||
console.log(`✅ Processing job started: ${jobId}`);
|
||
console.log('📊 The document will now be processed with LLM analysis');
|
||
console.log('🔍 Check the backend logs for processing progress');
|
||
|
||
} else {
|
||
console.log(`ℹ️ Document status is already: ${document.status}`);
|
||
}
|
||
|
||
} catch (error) {
|
||
console.error('❌ Error starting processing:', error.message);
|
||
} finally {
|
||
await pool.end();
|
||
}
|
||
}
|
||
|
||
startProcessing();
|