Files
L2keka/server/debug_std.js
T

44 lines
1.5 KiB
JavaScript
Raw 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');
// Replicate 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) });
}
return dims;
}
const std = db.prepare("SELECT * FROM standards WHERE name LIKE '%赛道一%'").get();
const dims = parseDimensions(std.content);
console.log('Content length:', std.content.length);
console.log('Dimensions found:', dims.length);
console.log('Total:', dims.reduce((s, d) => s + d.maxScore, 0));
// Try the exact operations from the route handler
try {
const dims2 = parseDimensions(std.content);
const passLine = Math.round(dims2.reduce((s, d) => s + d.maxScore, 0) * 0.6);
console.log('passLine:', passLine);
} catch(e) {
console.log('ERROR:', e.message);
}
// Try creating an entry manually
const id = require('crypto').randomUUID();
try {
db.prepare(`INSERT INTO entries (id, project_id, standard_id, title, repo_url, category_tag, participant, pass_line, standard_snapshot, branch)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`).run(
id, 'b1b5884e-ba85-4d8f-9a92-e524603587a0', std.id, 'Test', 'file://D:\\Projects\\kagedoku',
'赛道一', '', passLine, JSON.stringify(dims2), ''
);
console.log('Insert OK:', id);
db.prepare('DELETE FROM entries WHERE id = ?').run(id);
} catch(e) {
console.log('INSERT ERROR:', e.message);
}
db.close();