chore: CRM-NEW baseline
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
#!/usr/bin/env node
|
||||
'use strict';
|
||||
|
||||
// 质量日报:读取 bridge 库的 bridge_ai_metrics,输出最近 N 小时指标。
|
||||
const path = require('path');
|
||||
const { loadConfig } = require('../bridge/src/config');
|
||||
const { createMetrics } = require('../bridge/src/metrics');
|
||||
|
||||
const fs = require('fs');
|
||||
const envFile = path.resolve(__dirname, '..', '.env');
|
||||
const env = {};
|
||||
for (const line of fs.readFileSync(envFile, 'utf8').split('\n')) {
|
||||
if (!line.includes('=') || line.trim().startsWith('#')) continue;
|
||||
const i = line.indexOf('=');
|
||||
env[line.slice(0, i).trim()] = line.slice(i + 1).trim();
|
||||
}
|
||||
const password = encodeURIComponent(env.POSTGRES_PASSWORD || '');
|
||||
env.PG_URL = process.env.QUALITY_PG_URL || `postgres://crmnew:${password}@127.0.0.1:5440/bridge`;
|
||||
const cfg = loadConfig({ ...process.env, ...env });
|
||||
const hours = Number(process.argv[2]) || 24;
|
||||
|
||||
(async () => {
|
||||
const metrics = createMetrics(cfg);
|
||||
if (!metrics.enabled) throw new Error('PG_URL is not configured');
|
||||
const report = await metrics.report(hours);
|
||||
console.log(JSON.stringify(report, null, 2));
|
||||
await metrics.pool.end();
|
||||
})().catch((err) => {
|
||||
console.error('[quality-report]', err.message);
|
||||
process.exit(1);
|
||||
});
|
||||
Reference in New Issue
Block a user