37 lines
1.6 KiB
Python
Executable file
37 lines
1.6 KiB
Python
Executable file
import re
|
||
|
||
with open("/workspace/prds/index.html", "r", encoding="utf-8") as f:
|
||
html = f.read()
|
||
|
||
# 1. fix estimateDaysBE + estimateDaysFE
|
||
old_est = "<strong>${task.estimateDaysBE + task.estimateDaysFE} روز</strong>"
|
||
new_est = "<strong>${((task.estimateDaysBE || 0) + (task.estimateDaysFE || 0) || task.estimateDays || 0)} روز</strong>"
|
||
html = html.replace(old_est, new_est)
|
||
|
||
# 2. Add updateStats function inside script
|
||
stats_code = """
|
||
function updateStats() {
|
||
const total = prdsData.length;
|
||
const implemented = prdsData.filter(t => t.status === "implemented").length;
|
||
const backlog = prdsData.filter(t => t.status === "backlog").length;
|
||
const totalDays = prdsData.reduce((acc, t) => acc + ((t.estimateDaysBE || 0) + (t.estimateDaysFE || 0) || t.estimateDays || 0), 0);
|
||
|
||
const elTotal = document.getElementById("stat-total");
|
||
const elImp = document.getElementById("stat-implemented");
|
||
const elBacklog = document.getElementById("stat-backlog");
|
||
const elDays = document.getElementById("stat-days");
|
||
|
||
if (elTotal) elTotal.innerText = total.toLocaleString("fa-IR");
|
||
if (elImp) elImp.innerText = implemented.toLocaleString("fa-IR");
|
||
if (elBacklog) elBacklog.innerText = backlog.toLocaleString("fa-IR");
|
||
if (elDays) elDays.innerText = totalDays.toFixed(1).replace(".", "٫");
|
||
}
|
||
"""
|
||
|
||
if "function updateStats" not in html:
|
||
html = html.replace("function renderTasks() {", stats_code + "\n function renderTasks() {\n updateStats();")
|
||
|
||
with open("/workspace/prds/index.html", "w", encoding="utf-8") as f:
|
||
f.write(html)
|
||
|
||
print("Patched /workspace/prds/index.html successfully!")
|