Add dashboard completion metric
This commit is contained in:
@@ -370,6 +370,11 @@ def make_records() -> dict[str, Any]:
|
||||
item["rank"] = i
|
||||
no_score = [c for c in commodities if c["total"] is None]
|
||||
commodities = ranked + no_score
|
||||
completion_total = len(commodities)
|
||||
completion_count = sum(
|
||||
all(c["dims"].get(dim, {}).get("years") for dim in DIMENSIONS)
|
||||
for c in commodities
|
||||
)
|
||||
return {
|
||||
"generated_at": datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
|
||||
"source_files": {
|
||||
@@ -379,6 +384,11 @@ def make_records() -> dict[str, Any]:
|
||||
},
|
||||
"dimensions": DIMENSIONS + ["月差"],
|
||||
"boards": sorted(set(board for c in commodities for board in c.get("boards", [c["board"]]))),
|
||||
"completion": {
|
||||
"count": completion_count,
|
||||
"total": completion_total,
|
||||
"ratio": round(100.0 * completion_count / completion_total, 1) if completion_total else 0,
|
||||
},
|
||||
"commodities": commodities,
|
||||
}
|
||||
|
||||
@@ -488,7 +498,7 @@ svg {{ width:100%; height:230px; display:block; }}
|
||||
<button class="tabbtn" id="historyTab">评分走势</button>
|
||||
<button id="refreshData">刷新数据</button>
|
||||
<button id="reset">重置</button>
|
||||
<div class="stamp">核心修正:库存反向计分 生成时间:<span id="generated"></span></div>
|
||||
<div class="stamp">完成度:<span id="completion"></span> 核心修正:库存反向计分 生成时间:<span id="generated"></span></div>
|
||||
</div>
|
||||
<section class="summary">
|
||||
<div class="card">
|
||||
@@ -551,6 +561,7 @@ const refreshData = document.getElementById("refreshData");
|
||||
for (const d of dims) dimSel.append(new Option(d, d));
|
||||
for (const b of DATA.boards) boardSel.append(new Option(b, b));
|
||||
document.getElementById("generated").textContent = DATA.generated_at;
|
||||
document.getElementById("completion").textContent = `${{DATA.completion.count}}/${{DATA.completion.total}}(${{DATA.completion.ratio.toFixed(1)}}%)`;
|
||||
function todayString() {{
|
||||
const d = new Date();
|
||||
return `${{d.getFullYear()}}-${{String(d.getMonth()+1).padStart(2,"0")}}-${{String(d.getDate()).padStart(2,"0")}}`;
|
||||
|
||||
Reference in New Issue
Block a user