Files
L2keka/server/debug-insert.js
T

28 lines
1.2 KiB
JavaScript

const db = require('./dist/db').default || require('./dist/db');
const { parseDimensions } = require('./dist/routes/standards');
const crypto = require('crypto');
const projectId = 'b1b5884e-ba85-4d8f-9a92-e524603587a0';
const categoryTag = '赛道一';
const standard = db.prepare('SELECT * FROM standards WHERE project_id = ? AND category_tag = ?').get(projectId, categoryTag);
console.log('STANDARD:', standard ? { id: standard.id, name: standard.name } : null);
if (standard) {
const dims = parseDimensions(standard.content);
console.log('DIMS:', dims.length, 'TOTAL:', dims.reduce((s, d) => s + d.maxScore, 0));
const passLine = Math.round(dims.reduce((s, d) => s + d.maxScore, 0) * 0.6);
console.log('PASS_LINE:', passLine);
const id = 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, projectId, standard.id, 'test-direct', 'https://example.com/repo.git',
categoryTag, 'test', passLine, JSON.stringify(dims), ''
);
console.log('INSERT OK, ID:', id);
} catch (e) {
console.log('INSERT ERROR:', e.message);
}
}