From f81bff1043d59a2b4592435c19931cec4a98899a Mon Sep 17 00:00:00 2001 From: phact Date: Fri, 19 Sep 2025 11:22:01 -0400 Subject: [PATCH] task tracking running jobs --- .../src/components/task-notification-menu.tsx | 17 ++++++++++++-- src/services/task_service.py | 23 +++++++++++++++++++ 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/task-notification-menu.tsx b/frontend/src/components/task-notification-menu.tsx index c6f94959..0be471be 100644 --- a/frontend/src/components/task-notification-menu.tsx +++ b/frontend/src/components/task-notification-menu.tsx @@ -60,7 +60,9 @@ export function TaskNotificationMenu() { const processed = task.processed_files || 0 const successful = task.successful_files || 0 const failed = task.failed_files || 0 - + const running = task.running_files || 0 + const pending = task.pending_files || 0 + if (total > 0) { return { basic: `${processed}/${total} files`, @@ -69,6 +71,8 @@ export function TaskNotificationMenu() { processed, successful, failed, + running, + pending, remaining: total - processed } } @@ -196,10 +200,16 @@ export function TaskNotificationMenu() { {formatTaskProgress(task)?.detailed.failed} failed +
+
+ + {formatTaskProgress(task)?.detailed.running} running + +
- {formatTaskProgress(task)?.detailed.remaining} pending + {formatTaskProgress(task)?.detailed.pending} pending
@@ -288,6 +298,9 @@ export function TaskNotificationMenu() {
{formatTaskProgress(task)?.detailed.successful} success, {' '} {formatTaskProgress(task)?.detailed.failed} failed + {formatTaskProgress(task)?.detailed.running > 0 && ( + , {formatTaskProgress(task)?.detailed.running} running + )}
)} {task.status === 'failed' && task.error && ( diff --git a/src/services/task_service.py b/src/services/task_service.py index 0341aadf..c9328b90 100644 --- a/src/services/task_service.py +++ b/src/services/task_service.py @@ -220,6 +220,9 @@ class TaskService: return None file_statuses = {} + running_files_count = 0 + pending_files_count = 0 + for file_path, file_task in upload_task.file_tasks.items(): file_statuses[file_path] = { "status": file_task.status.value, @@ -231,6 +234,12 @@ class TaskService: "duration_seconds": file_task.duration_seconds, } + # Count running and pending files + if file_task.status.value == "running": + running_files_count += 1 + elif file_task.status.value == "pending": + pending_files_count += 1 + return { "task_id": upload_task.task_id, "status": upload_task.status.value, @@ -238,6 +247,8 @@ class TaskService: "processed_files": upload_task.processed_files, "successful_files": upload_task.successful_files, "failed_files": upload_task.failed_files, + "running_files": running_files_count, + "pending_files": pending_files_count, "created_at": upload_task.created_at, "updated_at": upload_task.updated_at, "duration_seconds": upload_task.duration_seconds, @@ -259,6 +270,16 @@ class TaskService: for task_id, upload_task in self.task_store[store_user_id].items(): if task_id in tasks_by_id: continue + + # Calculate running and pending counts + running_files_count = 0 + pending_files_count = 0 + for file_task in upload_task.file_tasks.values(): + if file_task.status.value == "running": + running_files_count += 1 + elif file_task.status.value == "pending": + pending_files_count += 1 + tasks_by_id[task_id] = { "task_id": upload_task.task_id, "status": upload_task.status.value, @@ -266,6 +287,8 @@ class TaskService: "processed_files": upload_task.processed_files, "successful_files": upload_task.successful_files, "failed_files": upload_task.failed_files, + "running_files": running_files_count, + "pending_files": pending_files_count, "created_at": upload_task.created_at, "updated_at": upload_task.updated_at, "duration_seconds": upload_task.duration_seconds,