Files
cim_summary/backend/test-upload-processing.js
Jon c67dab22b4 Add comprehensive CIM processing features and UI improvements
- 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
2025-07-27 20:25:46 -04:00

73 lines
2.9 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
const { Pool } = require('pg');
const fs = require('fs');
const path = require('path');
const pool = new Pool({
connectionString: 'postgresql://postgres:password@localhost:5432/cim_processor'
});
async function testUploadProcessing() {
try {
console.log('🧪 Testing Upload and Processing Pipeline');
console.log('==========================================');
// Check if we have any documents with 'uploaded' status
const uploadedDocs = await pool.query(`
SELECT id, original_file_name, status, created_at
FROM documents
WHERE status = 'uploaded'
ORDER BY created_at DESC
LIMIT 3
`);
console.log(`📋 Found ${uploadedDocs.rows.length} documents with 'uploaded' status:`);
uploadedDocs.rows.forEach(doc => {
console.log(` - ${doc.original_file_name} (${doc.status}) - ${doc.created_at}`);
});
if (uploadedDocs.rows.length === 0) {
console.log('❌ No documents with "uploaded" status found');
console.log('💡 Upload a new document through the frontend to test processing');
return;
}
// Check processing jobs
const processingJobs = await pool.query(`
SELECT id, document_id, type, status, progress, created_at
FROM processing_jobs
WHERE document_id IN (${uploadedDocs.rows.map(d => `'${d.id}'`).join(',')})
ORDER BY created_at DESC
`);
console.log(`\n🔧 Found ${processingJobs.rows.length} processing jobs:`);
processingJobs.rows.forEach(job => {
console.log(` - Job ${job.id}: ${job.type} (${job.status}) - ${job.progress}%`);
});
// Check if job queue service is running
console.log('\n🔍 Checking if job queue service is active...');
console.log('💡 The backend should automatically process documents when:');
console.log(' 1. A document is uploaded with processImmediately=true');
console.log(' 2. The job queue service is running');
console.log(' 3. Processing jobs are created in the database');
console.log('\n📊 Current Status:');
console.log(` - Documents uploaded: ${uploadedDocs.rows.length}`);
console.log(` - Processing jobs created: ${processingJobs.rows.length}`);
console.log(` - Jobs in pending status: ${processingJobs.rows.filter(j => j.status === 'pending').length}`);
console.log(` - Jobs in processing status: ${processingJobs.rows.filter(j => j.status === 'processing').length}`);
console.log(` - Jobs completed: ${processingJobs.rows.filter(j => j.status === 'completed').length}`);
if (processingJobs.rows.filter(j => j.status === 'pending').length > 0) {
console.log('\n⚠ There are pending jobs that should be processed automatically');
console.log('💡 This suggests the job queue worker might not be running');
}
} catch (error) {
console.error('❌ Error testing pipeline:', error.message);
} finally {
await pool.end();
}
}
testUploadProcessing();