auto-sync: 2026-05-18 12:08:26
This commit is contained in:
+12
-12
@@ -250,28 +250,23 @@ class Ticker:
|
||||
def _refresh_parent_statuses(self, db_path: Path) -> List[str]:
|
||||
"""全量扫描有子 Task 的父 Task,刷新聚合状态
|
||||
|
||||
跳过手动状态(cancelled)的父 Task。
|
||||
跳过手动状态(cancelled)的父 Task。使用单连接批量处理。
|
||||
"""
|
||||
queries = Queries(db_path)
|
||||
refreshed: List[str] = []
|
||||
|
||||
# 找出所有有子 Task 的父 Task ID
|
||||
conn = get_connection(db_path)
|
||||
try:
|
||||
# 找出所有有子 Task 的父 Task ID
|
||||
parent_rows = conn.execute(
|
||||
"SELECT DISTINCT parent_task FROM tasks WHERE parent_task IS NOT NULL"
|
||||
).fetchall()
|
||||
parent_ids = [r["parent_task"] for r in parent_rows]
|
||||
finally:
|
||||
conn.close()
|
||||
|
||||
for pid in parent_ids:
|
||||
computed = queries.compute_parent_status(pid)
|
||||
if computed is None:
|
||||
continue
|
||||
# 直接更新(跳过手动状态已在 compute 里判断)
|
||||
conn = get_connection(db_path)
|
||||
try:
|
||||
for pid in parent_ids:
|
||||
computed = queries.compute_parent_status(pid)
|
||||
if computed is None:
|
||||
continue
|
||||
parent = conn.execute(
|
||||
"SELECT status FROM tasks WHERE id=?", (pid,)
|
||||
).fetchone()
|
||||
@@ -280,9 +275,14 @@ class Ticker:
|
||||
"UPDATE tasks SET status=?, updated_at=datetime('now') WHERE id=?",
|
||||
(computed, pid),
|
||||
)
|
||||
conn.commit()
|
||||
refreshed.append(pid)
|
||||
logger.info("Parent %s status aggregated: → %s", pid, computed)
|
||||
|
||||
if refreshed:
|
||||
conn.commit()
|
||||
finally:
|
||||
conn.close()
|
||||
logger.info("Parent %s status aggregated: → %s", pid, computed)
|
||||
finally:
|
||||
conn.close()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user