fix(system): sort recent tasks by started_at desc

进行中任务可能尚无 finished_at;改为按 started_at 倒序,
缺开始时间的排末尾。测例用 finished 错开,避免误用完成时间。
This commit is contained in:
bot-ci committed 2026-11-02 19:38:34 +08:00
1 parent e7b48ba5d9
commit e6883f99a4
3 files changed
+23 -23

No files matched your search

+5 -5
View File
@@ -623,10 +623,10 @@ class DashboardQueries:
return None
@staticmethod
def _task_finished_sort_key(value: Any) -> tuple[int, int]:
"""缺 finished_at 的排末尾;有值的按完成时间倒序。"""
def _task_started_sort_key(value: Any) -> tuple[int, int]:
"""缺 started_at 的排末尾;有值的按开始时间倒序(含进行中)。"""
if isinstance(value, Mapping):
raw = value.get("finished_at")
raw = value.get("started_at")
try:
return (0, -int(raw))
except (TypeError, ValueError):
@@ -645,8 +645,8 @@ class DashboardQueries:
except (TypeError, json.JSONDecodeError):
value = {"raw": row["v"]}
items.append((name, value))
items.sort(key=lambda pair: self._task_finished_sort_key(pair[1]))
# 插入序即完成时间倒序;JSON/Object.entries 会保留。
items.sort(key=lambda pair: self._task_started_sort_key(pair[1]))
# 插入序即开始时间倒序;JSON/Object.entries 会保留。
return dict(items)
def _task_running(self, conn: sqlite3.Connection) -> dict[str, Any]: