fix(工作台): 视频拆解/视频分析字段映射修正闭环
- server.js 入库映射对齐 dsh 语义:content.json→source.content_json、analysis.json→source.analysis_json(视频拆解 tab)、*拆解分析.md→account_video_analysis(视频分析 tab) - 清理 6 条俊希错位 account_video_analysis + 白昼小熊 id13 归位 source47.analysis_json - 重跑入库验证:俊希 6 条 analysis_json 均写入、account_video_analysis 12 条=王微斯拆解分析(语义正确) - 王微斯视频三 tab 验证通过(视频脚本/视频拆解/视频分析各就其位) - 临时脚本已清理
This commit is contained in:
1 parent
a519948e6b
commit
787ececedb
5 files changed
+26
-12
No files matched your search
Binary file not shown.
@@ -3,9 +3,12 @@
|
||||
'use strict';
|
||||
|
||||
const fmt = (v) => (v == null || v === '') ? '-' : String(v);
|
||||
/* 过万数字以"万"为单位,保留一位小数(如 57141 → 5.7万) */
|
||||
/* 过万数字以"万"为单位,保留一位小数(如 57141 → 5.7万);已是"x.x万"文本(like_display 抖音原生格式)直接透传(09-01 修复:旧实现 Number('7.8万')=NaN→'-') */
|
||||
const fmtWan = (v) => {
|
||||
const n = Number(v);
|
||||
if (v == null || v === '') return '-';
|
||||
const s = String(v).trim();
|
||||
if (s.includes('万')) return s;
|
||||
const n = Number(s);
|
||||
if (!Number.isFinite(n) || n <= 0) return '-';
|
||||
return n >= 10000 ? (n / 10000).toFixed(1) + '万' : String(n);
|
||||
};
|
||||
@@ -295,11 +298,11 @@ async function renderAccountDetail(view, id) {
|
||||
<td>${fmt(v.publish_time)}</td>
|
||||
<td class="td-id"><a class="link" href="#/video/${v.id}" title="查看视频分析详情">${esc(v.aweme_id || '-')}</a></td>
|
||||
<td class="cell-content">${v.video_url ? `<a class="title-plain" data-ext="${esc(v.video_url)}" title="在新标签打开视频">${esc(cleanTitle(v.video_title) || '-')}</a>` : esc(cleanTitle(v.video_title) || '-')}</td>
|
||||
<td>${fmt(v.like_display || v.like_count)}</td>
|
||||
<td>${fmtWan(v.like_display || v.like_count)}</td>
|
||||
<td>${fmtWan(v.comment_count)}</td>
|
||||
<td>${fmtWan(v.share_count)}</td>
|
||||
<td>${fmtDuration(v.duration)}</td>
|
||||
<td class="cell-act"><button class="btn btn-sm ${(v.has_source || v.has_analysis) ? 'btn-view' : ''}" data-rewrite='${esc(JSON.stringify({ name: acc.account_name, title: cleanTitle(v.video_title), aweme: v.aweme_id, parsed: !!(v.has_source || v.has_analysis) }))}'>AI改写</button></td>
|
||||
<td class="cell-act"><button class="btn btn-sm ${(v.has_source || v.has_analysis) ? 'btn-view' : ''}" data-rewrite='${esc(JSON.stringify({ name: acc.account_name, title: cleanTitle(v.video_title), aweme: v.aweme_id, parsed: !!(v.has_source || v.has_analysis) }))}'>AI写作</button></td>
|
||||
</tr>`).join('');
|
||||
const tabBtns = [['info', '账号信息'], ['persona', '账号设定'], ['analysis', '数据分析']].map(([k, label]) => `<button class="tab ${tab === k ? 'tab-active' : ''}" data-tab="${k}">${label}</button>`).join('');
|
||||
let panel = '';
|
||||
|
||||
@@ -76,7 +76,7 @@ function importAccountIntoDb(db, account, dir) {
|
||||
const stats = { video_analysis: 0, video_source: 0, persona: 0, account_analysis: 0, videos_upserted: 0, skipped: [] };
|
||||
const now = new Date().toISOString();
|
||||
const insAnalysis = db.prepare(`INSERT INTO account_video_analysis (video_id, aweme_id, analysis_time, content_json, summary) VALUES (?,?,?,?,?)`);
|
||||
const insSource = db.prepare(`INSERT INTO account_video_source (video_id, aweme_id, analysis_time, content_json, summary) VALUES (?,?,?,?,?)`);
|
||||
const insSource = db.prepare(`INSERT INTO account_video_source (video_id, aweme_id, analysis_time, content_json, summary, analysis_json) VALUES (?,?,?,?,?,?)`);
|
||||
const insPersona = db.prepare(`INSERT INTO account_persona (account_id, analysis_time, content_json, summary) VALUES (?,?,?,?)`);
|
||||
const insAccAna = db.prepare(`INSERT INTO account_analysis (account_id, analysis_time, content_json, summary) VALUES (?,?,?,?)`);
|
||||
const acc = db.prepare('SELECT id FROM hot_accounts WHERE account_name=? LIMIT 1').get(account);
|
||||
@@ -123,6 +123,9 @@ function importAccountIntoDb(db, account, dir) {
|
||||
}
|
||||
}
|
||||
// 1) 视频分析目录(功能三 Step5 产出;功能五产出在 视频对标/ 目录,由 dsh 导入机制处理)
|
||||
// 字段映射(09-01 修正,对齐 dsh 语义):content.json→account_video_source.content_json(视频脚本);
|
||||
// analysis.json→account_video_source.analysis_json(视频拆解,MCP 结构化分析);*拆解分析.md→account_video_analysis(视频分析,功能四产物)。
|
||||
// 原实现把 analysis.json 误写 account_video_analysis 导致「拆解内容进了视频分析」+「视频拆解 tab 空」
|
||||
const vaDir = path.join(dir, '视频分析');
|
||||
if (fs.existsSync(vaDir)) {
|
||||
for (const folder of fs.readdirSync(vaDir)) {
|
||||
@@ -131,19 +134,22 @@ function importAccountIntoDb(db, account, dir) {
|
||||
if (!st.isDirectory()) continue;
|
||||
const awemeId = matchAweme(folder);
|
||||
const anPath = path.join(fdir, 'analysis.json');
|
||||
if (fs.existsSync(anPath)) {
|
||||
const content = fs.readFileSync(anPath, 'utf8');
|
||||
if (awemeId) db.prepare('DELETE FROM account_video_analysis WHERE aweme_id=?').run(awemeId);
|
||||
insAnalysis.run(null, awemeId, now, content, content.slice(0, 500));
|
||||
stats.video_analysis++;
|
||||
}
|
||||
const coPath = path.join(fdir, 'content.json');
|
||||
if (fs.existsSync(coPath)) {
|
||||
const content = fs.readFileSync(coPath, 'utf8');
|
||||
const analysisJson = fs.existsSync(anPath) ? fs.readFileSync(anPath, 'utf8') : null;
|
||||
if (awemeId) db.prepare('DELETE FROM account_video_source WHERE aweme_id=?').run(awemeId);
|
||||
insSource.run(null, awemeId, now, content, '');
|
||||
insSource.run(null, awemeId, now, content, '', analysisJson);
|
||||
stats.video_source++;
|
||||
}
|
||||
// 拆解分析.md → account_video_analysis(功能四逐条拆解产物,与解析并存于同一文件夹;无则不入)
|
||||
const decon = fs.readdirSync(fdir).find((f) => f.endsWith('拆解分析.md'));
|
||||
if (decon) {
|
||||
const content = fs.readFileSync(path.join(fdir, decon), 'utf8');
|
||||
if (awemeId) db.prepare('DELETE FROM account_video_analysis WHERE aweme_id=?').run(awemeId);
|
||||
insAnalysis.run(null, awemeId, now, content, content.slice(0, 500));
|
||||
stats.video_analysis++;
|
||||
}
|
||||
}
|
||||
}
|
||||
// 2) 人设卡 + 账号分析(去重,不删旧)
|
||||
|
||||
Reference in new issue
Block a user