Spaces:
Paused
Paused
File size: 2,627 Bytes
34367da | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | import 'dotenv/config';
import * as fs from 'fs';
import * as path from 'path';
import { fileURLToPath } from 'url';
import neo4j from 'neo4j-driver';
// ESM Shim
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const REPORT_PATH = path.resolve(__dirname, '../../../../market_fit_report.json');
async function runMarketAnalysis() {
console.log('π Operation Market Fit: Initializing...');
// Cloud Connection
const driver = neo4j.driver(
process.env.NEO4J_URI!,
neo4j.auth.basic(process.env.NEO4J_USER!, process.env.NEO4J_PASSWORD!)
);
const session = driver.session();
try {
console.log('π Connecting to Neural Graph...');
// RETTET QUERY: Henter data fra relationen POTENTIAL_FIT
const result = await session.run(`
MATCH (org:Organization)-[r:POTENTIAL_FIT]->(t:Tender)
MATCH (b:Buyer)-[:ISSUED]->(t)
RETURN
t.title as title,
b.name as buyer,
r.score as score,
r.matches as capabilities,
r.upscale as isUpscale,
r.rationale as rationale,
t.url as url
ORDER BY r.score DESC
`);
const opportunities = result.records.map(record => ({
title: record.get('title'),
buyer: record.get('buyer'),
score: record.get('score'), // Match %
capabilities: record.get('capabilities'), // Hvad vi kan
isUpscale: record.get('isUpscale'), // Er det R&D?
rationale: record.get('rationale'),
url: record.get('url'),
// Simuleret "Missing" (I fremtiden kan vi sammenligne med t.description)
status: record.get('score') > 80 ? 'STRONG FIT' : 'DEVELOPMENT NEEDED'
}));
console.log(`β
Analysis Complete. Found ${opportunities.length} strategic opportunities.`);
// Gem rapporten
fs.writeFileSync(REPORT_PATH, JSON.stringify({
generatedAt: new Date().toISOString(),
count: opportunities.length,
opportunities: opportunities
}, null, 2));
console.log(`π Report saved to: ${REPORT_PATH}`);
// Vis preview i konsollen
if (opportunities.length > 0) {
console.log('\nTop Opportunity:');
console.log(`π― ${opportunities[0].title}`);
console.log(` Score: ${opportunities[0].score}%`);
console.log(` Matches: ${opportunities[0].capabilities.join(', ')}`);
}
} catch (error) {
console.error('β Analysis Failure:', error);
} finally {
await session.close();
await driver.close();
}
}
runMarketAnalysis();
|