fix: 功能树只显示position-analyst(知微)的cron,default(莫荷)的cron不混入

This commit is contained in:
知微
2026-07-08 17:25:08 +08:00
parent 5239f481b0
commit ab85173902
2 changed files with 19 additions and 7 deletions
+10 -2
View File
@@ -77,11 +77,13 @@ def load_cron_jobs():
jobs = []
seen = set()
for jf in CRON_FILES:
profile_tag = "position-analyst" if "position-analyst" in str(jf) else "default"
try:
for j in json.load(open(jf)).get("jobs", []):
jid = j.get("id", "")
if jid in seen: continue
seen.add(jid)
j["profile"] = profile_tag
jobs.append(j)
except: pass
return jobs
@@ -240,6 +242,7 @@ def build_feature_tree(cron_jobs, db_stats):
"status": j.get("last_status", "unknown"),
"last_run": (j.get("last_run_at", "") or "")[:16] if j.get("last_run_at") else "",
"type": "no_agent" if j.get("no_agent") else "LLM",
"profile": j.get("profile", "?"),
} for j in matched]
if pipes:
node["pipes"] = pipes
@@ -258,6 +261,7 @@ def build_feature_tree(cron_jobs, db_stats):
"status": j.get("last_status", "unknown"),
"last_run": (j.get("last_run_at", "") or "")[:16] if j.get("last_run_at") else "",
"type": "no_agent" if j.get("no_agent") else "LLM",
"profile": j.get("profile", "?"),
}]
}
@@ -365,8 +369,11 @@ def build_report():
flows = scan_data_flows()
script_health = check_scripts()
# ── 功能树 ──
feature_tree = build_feature_tree(cron_jobs, db_stats)
# ── 功能树(只显示知微的cron──
zhiwei_crons = [j for j in cron_jobs if j.get("profile") == "position-analyst" or j.get("name") in [
"cron-推XMPP中继", "数据同步-dashboard", "记忆守卫-每日", "市场数据采集"
]]
feature_tree = build_feature_tree(zhiwei_crons, db_stats)
# 递归计算节点状态
def calc_status(node):
if "children" in node:
@@ -435,6 +442,7 @@ def build_report():
"schedule": schedule,
"status": status,
"last_run": last_run,
"profile": j.get("profile", "?"),
})
# ── 写JSON ──
+9 -5
View File
@@ -48,7 +48,7 @@ td.wrap{white-space:normal;font-size:11px;max-width:200px}
<div class="summary" id="summary">加载中...</div>
<div class="tabs">
<div class="tab active" onclick="switchTab(0)">🌳 功能树</div>
<div class="tab" onclick="switchTab(1)">🔧 全部流程/Cron (77)</div>
<div class="tab" onclick="switchTab(1)">🔧 全部流程/Cron</div>
<div class="tab" onclick="switchTab(2)">🗃️ 数据实体</div>
</div>
@@ -65,7 +65,7 @@ function switchTab(idx) {
}
function renderFeatureTree(tree) {
let html = '<table><thead><tr><th style="width:50%">功能模块</th><th>类型</th><th>调度</th><th>状态</th><th>最后运行</th></tr></thead><tbody>';
let html = '<table><thead><tr><th style="width:40%">功能模块</th><th>来源</th><th>类型</th><th>调度</th><th>状态</th><th>最后运行</th></tr></thead><tbody>';
function walk(node, depth) {
const indent = 'style="padding-left:'+(depth*20+8)+'px"';
const cls = node.status || 'ok';
@@ -76,17 +76,19 @@ function renderFeatureTree(tree) {
if (pipes.length === 0) {
// 无对应cron的功能节点
html += `<tr><td ${indent}><span class="badge ${cls}"></span><strong>${node.label}</strong><span class="cron-detail">(纯逻辑节点)</span></td>`;
html += `<td>-</td><td>-</td><td class="pipeline-${cls==='ok'?'ok':'warn'}">${cls}</td><td>-</td></tr>`;
html += `<td>-</td><td>-</td><td>-</td><td class="pipeline-${cls==='ok'?'ok':'warn'}">${cls}</td><td>-</td></tr>`;
} else {
// 有对应cron的节点
pipes.forEach((p, i) => {
const indent2 = i===0 ? indent : 'style="padding-left:'+(depth*20+32)+'px"';
const tagCls = p.status==='ok'?'ok':p.status==='error'?'error':'warn';
const profileBadge = p.profile==='position-analyst' ? '📋' : '📦';
if (i===0) {
html += `<tr><td ${indent2}><span class="badge ${cls}"></span><strong>${node.label}</strong></td>`;
} else {
html += `<tr><td ${indent2}><span style="color:#30363d">└</span> ${p.name||p.script||'LLM'}</td>`;
}
html += `<td style="font-size:11px">${profileBadge} ${p.profile||'?'}</td>`;
html += `<td><span class="cron-tag ${tagCls}">${p.type||'LLM'}</span></td>`;
html += `<td style="font-size:11px">${p.schedule||'-'}</td>`;
html += `<td class="pipeline-${tagCls}">${p.status}</td>`;
@@ -103,13 +105,15 @@ function renderFeatureTree(tree) {
function renderPipelineTable(pipelines) {
let html = '<input class="search-box" id="pipeSearch" placeholder="搜索流程..." oninput="filterPipes()">';
html += '<table><thead><tr><th>名称</th><th>脚本/LLM</th><th>类型</th><th>调度</th><th>状态</th><th>最后运行</th></tr></thead><tbody id="pipeBody">';
html += '<table><thead><tr><th>名称</th><th>来源</th><th>脚本/LLM</th><th>类型</th><th>调度</th><th>状态</th><th>最后运行</th></tr></thead><tbody id="pipeBody">';
pipelines.forEach(p => {
const tagCls = p.status==='ok'?'ok':p.status==='error'?'error':'warn';
const statusDisplay = p.last_run ? p.status : '待首次运行';
const profileBadge = p.profile==='position-analyst' ? '📋' : '📦';
html += `<tr class="pipe-row"><td>${p.name||p.script||'LLM'}</td>`;
html += `<td style="font-size:11px">${profileBadge} ${p.profile||'?'}</td>`;
html += `<td style="font-size:11px">${p.script||'LLM'}</td>`;
html += `<td><span class="cron-tag ${tagCls}">${p.type||cron}</span></td>`;
html += `<td><span class="cron-tag ${tagCls}">${p.type||'cron'}</span></td>`;
html += `<td style="font-size:11px">${p.schedule||'-'}</td>`;
html += `<td class="pipeline-${tagCls}">${statusDisplay}</td>`;
html += `<td style="font-size:11px">${p.last_run||'-'}</td></tr>`;