Show waiting tasks accurately in operations views

This commit is contained in:
wuyang
2026-11-05 11:02:42 +08:00
parent f882c9a831
commit 5e7cae0bee
5 changed files with 27 additions and 10 deletions
+4 -3
View File
@@ -234,9 +234,10 @@ def build_report(data_dir, snapshot=False, now=None):
next_actions = [i['title'] for i in tasks.get('items', []) if i.get('status') in ('todo', 'in_progress')][:8]
# A task queue is a current snapshot; it does not reconstruct the past reporting period.
if isinstance(queue, dict) and queue.get('schema') == 1 and isinstance(queue.get('tasks'), list):
safe = [i for i in queue['tasks'] if isinstance(i, dict) and i.get('status') in ('pending', 'running', 'blocked') and isinstance(i.get('title'), str) and isinstance(i.get('id'), str)]
safe.sort(key=lambda i: (0 if i['status'] == 'running' else 1 if i['status'] == 'pending' else 2, i.get('updated_at') or ''))
next_actions = [('核查新互动' if i['id'].startswith('interaction-') else i['title'][:100]) + ('(已阻塞)' if i['status'] == 'blocked' else '') for i in safe[:8]]
safe = [i for i in queue['tasks'] if isinstance(i, dict) and i.get('status') in ('pending', 'running', 'waiting', 'blocked') and isinstance(i.get('title'), str) and isinstance(i.get('id'), str)]
safe = [{**i, 'status': 'waiting' if i['status'] == 'pending' and i.get('dispatch_ready') is not True else i['status']} for i in safe]
safe.sort(key=lambda i: (0 if i['status'] == 'running' else 1 if i['status'] == 'pending' else 2 if i['status'] == 'waiting' else 3, i.get('updated_at') or ''))
next_actions = [('核查新互动' if i['id'].startswith('interaction-') else i['title'][:100]) + ('(已阻塞)' if i['status'] == 'blocked' else '(等待触发条件)' if i['status'] == 'waiting' else '') for i in safe[:8]]
current = next(({'title': '核查新互动' if i['id'].startswith('interaction-') else i['title'][:100]} for i in safe if i['status'] == 'running'), None)
identifier = end.strftime('%G-W%V') + ('-snapshot-' + now.strftime('%Y%m%dT%H%M%S') if snapshot else '')