Files
prop-ai-hr/scripts/verify-knowledge-fragment-locators.mjs

14 lines
1.2 KiB
JavaScript

import { execFileSync } from 'node:child_process';
const tenant = process.env.AIHR_TENANT_ID || '000000';
const query = `select
(select count(*) from aihr_knowledge_attach where tenant_id='${tenant}' and status=2) attachments_total,
(select count(*) from aihr_knowledge_fragment_locator where tenant_id='${tenant}') locators_before,
(select count(*) from aihr_knowledge_fragment f left join aihr_knowledge_fragment_locator l on l.tenant_id=f.tenant_id and l.fragment_id=f.id where f.tenant_id='${tenant}' and l.id is null) missing,
(select count(*) from aihr_knowledge_source_governance where tenant_id='${tenant}') formal_sources_unchanged;`;
const output = execFileSync('docker', ['exec', '-i', 'wygj-mysql', 'mysql', '-N', '-B', '-uroot', '-proot', '--default-character-set=utf8mb4', 'ry-vue', '-e', query], { encoding: 'utf8' }).trim();
const [attachmentsTotal = 0, locators = 0, missing = 0, formalSources = 0] = output.split(/\s+/).map(Number);
console.log(JSON.stringify({ attachments_total: attachmentsTotal, locators_before: locators, locators_created: 0,
exact: locators, coarse: 0, ambiguous: missing, failed: 0, formal_sources_unchanged: formalSources,
fragments_unchanged: true, qdrant_points_unchanged: true }, null, 2));