pipeline_ops/wwwroot/api/ops_dashboard_data.dspy
yumoqing e76bb3db60 feat: UI pages, build.sh, deployment scripts, model uitype fixes
- Add SDLC dashboard, pipeline editor, ops center UI
- build.sh: clone business modules to pkgs/, xls2ui CRUD, fix created_by
- global_func.py: password_encode None-safe wrapper
- pipeline_app.py: permission cache warmup removed
- load_path.py: RBAC permission registration for all modules
- scripts/merge_i18n.py: i18n merge tool
- bin/init_perms.py, bin/init_data.py: init scripts
- set_role_perm.py: single permission registration
- Model uitype fields set for form editing
- pipeline_core/pipeline_ops load_path.py scripts
2026-08-03 16:20:27 +08:00

62 lines
2.2 KiB
Plaintext

"""
Operations Dashboard Data: task queue, human tasks, stats
"""
from sqlor.dbpools import DBPools
async def main():
dbname = get_module_dbname('pipeline_core')
async with DBPools().sqlorContext(dbname) as sor:
# Task stats by state
task_stats = await sor.sqlExe("""
SELECT state, COUNT(*) as cnt FROM pipeline_tasks
GROUP BY state ORDER BY cnt DESC
""", {})
stats = {'submitted':0, 'running':0, 'completed':0, 'failed':0, 'cancelled':0}
for r in task_stats:
stats[r.state] = r.cnt
# Recent tasks (last 20)
tasks = await sor.sqlExe("""
SELECT t.id, t.title, t.state, t.pipeline_id, t.created_at
FROM pipeline_tasks t
ORDER BY t.created_at DESC LIMIT 20
""", {})
task_list = []
for r in tasks:
task_list.append({
'id': r.id, 'title': r.title, 'state': r.state,
'pipeline_id': r.pipeline_id, 'created_at': str(r.created_at)[:19]
})
# Pending human tasks
human_tasks = await sor.sqlExe("""
SELECT h.id, h.task_id, h.task_type, h.step_name, h.status,
h.assignee_role, h.created_at, h.expired_at,
t.title as task_title
FROM pipeline_human_tasks h
LEFT JOIN pipeline_tasks t ON h.task_id = t.id
WHERE h.status IN ('pending', 'in_progress')
ORDER BY h.created_at DESC LIMIT 20
""", {})
human_list = []
for r in human_tasks:
human_list.append({
'id': r.id, 'task_id': r.task_id, 'task_type': r.task_type,
'step_name': r.step_name, 'status': r.status,
'assignee_role': r.assignee_role, 'task_title': r.task_title,
'created_at': str(r.created_at)[:19],
'expired_at': str(r.expired_at)[:19] if r.expired_at else None
})
return {
'stats': stats,
'tasks': task_list,
'human_tasks': human_list,
'total_tasks': sum(stats.values()),
'active_tasks': stats['running'],
'pending_reviews': len(human_list)
}