Files
L2keka/server/verify_standards.js

30 lines
947 B
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
const Database = require('better-sqlite3');
const db = new Database('data/ai-review.db');
// Manual parseDimensions
function parseDimensions(md) {
const dims = [];
const re = /##\s+(.+?)(\d+)[分%]\s*([\s\S]*?)(?=\n##\s|\n*$)/g;
let match;
while ((match = re.exec(md)) !== null) {
dims.push({ name: match[1].trim(), maxScore: parseInt(match[2], 10), content: match[3].trim().slice(0, 60) });
}
return dims;
}
const ids = [
'996fa0b9-13d3-4f2f-ab32-7ce1aba14723',
'48e1344e-9ae5-4a74-b7c9-f22cd0a4c1d4',
];
for (const id of ids) {
const row = db.prepare('SELECT name, content FROM standards WHERE id = ?').get(id);
const dims = parseDimensions(row.content);
const total = dims.reduce((s, d) => s + d.maxScore, 0);
console.log(`\n${row.name}:`);
dims.forEach(d => console.log(` ${d.name} (${d.maxScore})`));
console.log(` 总分: ${total} ${total === 150 ? '✅' : '⚠️ 不等于150'}`);
}
db.close();