首页AI脚本卡片右下角显示脚本评分:listRecentScripts 关联最新 AI 复盘总分,无评分不显示徽章

This commit is contained in:
maogeigei committed 2026-09-03 15:30:33 +08:00
1 parent 0f315de830
commit 4f4e126e61
4 files changed
+23 -7

No files matched your search

@@ -311,13 +311,18 @@ function getStats() {
};
}
// 最近 AI 写剧本(首页快捷卡片):status=done 且有内容,按 id 倒序取前 N 条
// 最近 AI 写剧本(首页快捷卡片):status=done 且有内容,按 id 倒序取前 N 条;
// score = 该脚本最新一条已完成 AI 复盘(script_review type='ai')的总分,无复盘则为 null
function listRecentScripts(limit = 4) {
const d = getDb(); if (!d) return [];
const n = Math.max(1, Math.min(Number(limit) || 4, 20));
return d.prepare(`
SELECT r.id, r.title, r.script_text, r.created_time, r.video_id, r.account_id,
h.account_name, v.video_title
h.account_name, v.video_title,
(SELECT sr.total FROM script_review sr
WHERE sr.type='ai' AND sr.rewrite_id = r.id AND sr.status='done'
AND sr.total IS NOT NULL AND sr.total <> ''
ORDER BY sr.id DESC LIMIT 1) AS score
FROM rewrite_log r
LEFT JOIN hot_accounts h ON h.id = r.account_id
LEFT JOIN account_videos v ON v.id = r.video_id