first commit
This commit is contained in:
21
backend/backfill-ai.ts
Normal file
21
backend/backfill-ai.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import * as dotenv from 'dotenv';
|
||||
dotenv.config();
|
||||
import pool from './src/config/database';
|
||||
|
||||
async function run() {
|
||||
const [results] = await pool.query<any[]>('SELECT ai_id, perf_id, ai_score_json FROM ai_result');
|
||||
for (const row of results) {
|
||||
const items = JSON.parse(row.ai_score_json);
|
||||
for (const item of items) {
|
||||
await pool.query(
|
||||
'UPDATE perf_item SET ai_score = ?, ai_explanation = ? WHERE perf_id = ? AND item_name = ?',
|
||||
[item.aiScore, item.scoreExplanation, row.perf_id, item.itemName]
|
||||
);
|
||||
}
|
||||
console.log(`回写 perfId=${row.perf_id},共 ${items.length} 项`);
|
||||
}
|
||||
await pool.end();
|
||||
console.log('完成');
|
||||
}
|
||||
|
||||
run().catch(console.error);
|
||||
Reference in New Issue
Block a user