Some checks failed
CI/CD Pipeline / Backend - Lint & Test (push) Has been cancelled
CI/CD Pipeline / Frontend - Lint & Test (push) Has been cancelled
CI/CD Pipeline / Security Scan (push) Has been cancelled
CI/CD Pipeline / Build Backend (push) Has been cancelled
CI/CD Pipeline / Build Frontend (push) Has been cancelled
CI/CD Pipeline / Integration Tests (push) Has been cancelled
CI/CD Pipeline / Deploy to Staging (push) Has been cancelled
CI/CD Pipeline / Deploy to Production (push) Has been cancelled
CI/CD Pipeline / Performance Tests (push) Has been cancelled
CI/CD Pipeline / Dependency Updates (push) Has been cancelled
- Updated Anthropic API to latest version (2024-01-01) - Set Claude 3.7 Sonnet Latest as primary model - Removed deprecated Opus 3.5 references - Fixed LLM response validation and JSON parsing - Improved error handling and logging - Updated model configurations and pricing - Enhanced document processing reliability - Fixed TypeScript type issues - Updated environment configuration
150 lines
5.2 KiB
JavaScript
150 lines
5.2 KiB
JavaScript
const { Pool } = require('pg');
|
|
const path = require('path');
|
|
|
|
// Load environment variables from the testing environment
|
|
require('dotenv').config({ path: path.join(__dirname, '.env') });
|
|
|
|
console.log('🔧 Environment check:');
|
|
console.log(' DATABASE_URL:', process.env.DATABASE_URL ? 'Set' : 'Not set');
|
|
console.log(' NODE_ENV:', process.env.NODE_ENV || 'Not set');
|
|
console.log('');
|
|
|
|
const pool = new Pool({
|
|
connectionString: process.env.DATABASE_URL,
|
|
ssl: process.env.NODE_ENV === 'production' ? { rejectUnauthorized: false } : false
|
|
});
|
|
|
|
// Test connection
|
|
pool.on('error', (err) => {
|
|
console.error('❌ Database connection error:', err);
|
|
});
|
|
|
|
async function checkAnalysisData() {
|
|
try {
|
|
console.log('🔍 Checking analysis data in database...\n');
|
|
|
|
// Check recent documents with analysis_data
|
|
const result = await pool.query(`
|
|
SELECT
|
|
id,
|
|
original_file_name,
|
|
status,
|
|
analysis_data,
|
|
processing_completed_at,
|
|
created_at
|
|
FROM documents
|
|
WHERE analysis_data IS NOT NULL
|
|
ORDER BY created_at DESC
|
|
LIMIT 5
|
|
`);
|
|
|
|
console.log(`📊 Found ${result.rows.length} documents with analysis_data:\n`);
|
|
|
|
result.rows.forEach((row, index) => {
|
|
console.log(`📄 Document ${index + 1}:`);
|
|
console.log(` ID: ${row.id}`);
|
|
console.log(` Name: ${row.original_file_name}`);
|
|
console.log(` Status: ${row.status}`);
|
|
console.log(` Created: ${row.created_at}`);
|
|
console.log(` Completed: ${row.processing_completed_at}`);
|
|
|
|
if (row.analysis_data) {
|
|
console.log(` Analysis Data Keys: ${Object.keys(row.analysis_data).join(', ')}`);
|
|
|
|
// Check if the data has the expected structure
|
|
const expectedSections = [
|
|
'dealOverview',
|
|
'businessDescription',
|
|
'marketIndustryAnalysis',
|
|
'financialSummary',
|
|
'managementTeamOverview',
|
|
'preliminaryInvestmentThesis',
|
|
'keyQuestionsNextSteps'
|
|
];
|
|
|
|
const missingSections = expectedSections.filter(section => !row.analysis_data[section]);
|
|
const presentSections = expectedSections.filter(section => row.analysis_data[section]);
|
|
|
|
console.log(` ✅ Present Sections: ${presentSections.join(', ')}`);
|
|
if (missingSections.length > 0) {
|
|
console.log(` ❌ Missing Sections: ${missingSections.join(', ')}`);
|
|
}
|
|
|
|
// Check if sections have actual data (not just empty objects)
|
|
const emptySections = presentSections.filter(section => {
|
|
const sectionData = row.analysis_data[section];
|
|
return !sectionData || Object.keys(sectionData).length === 0 ||
|
|
(typeof sectionData === 'object' && Object.values(sectionData).every(val =>
|
|
!val || val === '' || val === 'N/A' || val === 'Not specified in CIM'
|
|
));
|
|
});
|
|
|
|
if (emptySections.length > 0) {
|
|
console.log(` ⚠️ Empty Sections: ${emptySections.join(', ')}`);
|
|
}
|
|
|
|
// Show a sample of the data
|
|
if (row.analysis_data.dealOverview) {
|
|
console.log(` 📋 Sample - Deal Overview:`);
|
|
console.log(` Target Company: ${row.analysis_data.dealOverview.targetCompanyName || 'N/A'}`);
|
|
console.log(` Industry: ${row.analysis_data.dealOverview.industrySector || 'N/A'}`);
|
|
}
|
|
|
|
} else {
|
|
console.log(` ❌ No analysis_data found`);
|
|
}
|
|
|
|
console.log('');
|
|
});
|
|
|
|
// Check documents without analysis_data
|
|
const noAnalysisResult = await pool.query(`
|
|
SELECT
|
|
id,
|
|
original_file_name,
|
|
status,
|
|
processing_completed_at,
|
|
created_at
|
|
FROM documents
|
|
WHERE analysis_data IS NULL
|
|
AND status = 'completed'
|
|
ORDER BY created_at DESC
|
|
LIMIT 3
|
|
`);
|
|
|
|
if (noAnalysisResult.rows.length > 0) {
|
|
console.log(`⚠️ Found ${noAnalysisResult.rows.length} completed documents WITHOUT analysis_data:\n`);
|
|
noAnalysisResult.rows.forEach((row, index) => {
|
|
console.log(` ${index + 1}. ${row.original_file_name} (${row.status}) - ${row.created_at}`);
|
|
});
|
|
console.log('');
|
|
}
|
|
|
|
// Check total document counts
|
|
const totalResult = await pool.query(`
|
|
SELECT
|
|
COUNT(*) as total_documents,
|
|
COUNT(CASE WHEN analysis_data IS NOT NULL THEN 1 END) as with_analysis,
|
|
COUNT(CASE WHEN analysis_data IS NULL THEN 1 END) as without_analysis,
|
|
COUNT(CASE WHEN status = 'completed' THEN 1 END) as completed,
|
|
COUNT(CASE WHEN status = 'failed' THEN 1 END) as failed
|
|
FROM documents
|
|
`);
|
|
|
|
const stats = totalResult.rows[0];
|
|
console.log(`📈 Database Statistics:`);
|
|
console.log(` Total Documents: ${stats.total_documents}`);
|
|
console.log(` With Analysis Data: ${stats.with_analysis}`);
|
|
console.log(` Without Analysis Data: ${stats.without_analysis}`);
|
|
console.log(` Completed: ${stats.completed}`);
|
|
console.log(` Failed: ${stats.failed}`);
|
|
|
|
} catch (error) {
|
|
console.error('❌ Error checking analysis data:', error);
|
|
} finally {
|
|
await pool.end();
|
|
}
|
|
}
|
|
|
|
checkAnalysisData();
|