task tracking running jobs
This commit is contained in:
parent
9d57c352e8
commit
f81bff1043
2 changed files with 38 additions and 2 deletions
|
|
@ -60,7 +60,9 @@ export function TaskNotificationMenu() {
|
||||||
const processed = task.processed_files || 0
|
const processed = task.processed_files || 0
|
||||||
const successful = task.successful_files || 0
|
const successful = task.successful_files || 0
|
||||||
const failed = task.failed_files || 0
|
const failed = task.failed_files || 0
|
||||||
|
const running = task.running_files || 0
|
||||||
|
const pending = task.pending_files || 0
|
||||||
|
|
||||||
if (total > 0) {
|
if (total > 0) {
|
||||||
return {
|
return {
|
||||||
basic: `${processed}/${total} files`,
|
basic: `${processed}/${total} files`,
|
||||||
|
|
@ -69,6 +71,8 @@ export function TaskNotificationMenu() {
|
||||||
processed,
|
processed,
|
||||||
successful,
|
successful,
|
||||||
failed,
|
failed,
|
||||||
|
running,
|
||||||
|
pending,
|
||||||
remaining: total - processed
|
remaining: total - processed
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -196,10 +200,16 @@ export function TaskNotificationMenu() {
|
||||||
{formatTaskProgress(task)?.detailed.failed} failed
|
{formatTaskProgress(task)?.detailed.failed} failed
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
<div className="flex items-center gap-1">
|
||||||
|
<div className="w-2 h-2 bg-blue-500 rounded-full"></div>
|
||||||
|
<span className="text-blue-600">
|
||||||
|
{formatTaskProgress(task)?.detailed.running} running
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
<div className="flex items-center gap-1">
|
<div className="flex items-center gap-1">
|
||||||
<div className="w-2 h-2 bg-yellow-500 rounded-full"></div>
|
<div className="w-2 h-2 bg-yellow-500 rounded-full"></div>
|
||||||
<span className="text-yellow-600">
|
<span className="text-yellow-600">
|
||||||
{formatTaskProgress(task)?.detailed.remaining} pending
|
{formatTaskProgress(task)?.detailed.pending} pending
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -288,6 +298,9 @@ export function TaskNotificationMenu() {
|
||||||
<div className="text-xs text-muted-foreground mt-1">
|
<div className="text-xs text-muted-foreground mt-1">
|
||||||
{formatTaskProgress(task)?.detailed.successful} success, {' '}
|
{formatTaskProgress(task)?.detailed.successful} success, {' '}
|
||||||
{formatTaskProgress(task)?.detailed.failed} failed
|
{formatTaskProgress(task)?.detailed.failed} failed
|
||||||
|
{formatTaskProgress(task)?.detailed.running > 0 && (
|
||||||
|
<span>, {formatTaskProgress(task)?.detailed.running} running</span>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{task.status === 'failed' && task.error && (
|
{task.status === 'failed' && task.error && (
|
||||||
|
|
|
||||||
|
|
@ -220,6 +220,9 @@ class TaskService:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
file_statuses = {}
|
file_statuses = {}
|
||||||
|
running_files_count = 0
|
||||||
|
pending_files_count = 0
|
||||||
|
|
||||||
for file_path, file_task in upload_task.file_tasks.items():
|
for file_path, file_task in upload_task.file_tasks.items():
|
||||||
file_statuses[file_path] = {
|
file_statuses[file_path] = {
|
||||||
"status": file_task.status.value,
|
"status": file_task.status.value,
|
||||||
|
|
@ -231,6 +234,12 @@ class TaskService:
|
||||||
"duration_seconds": file_task.duration_seconds,
|
"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 {
|
return {
|
||||||
"task_id": upload_task.task_id,
|
"task_id": upload_task.task_id,
|
||||||
"status": upload_task.status.value,
|
"status": upload_task.status.value,
|
||||||
|
|
@ -238,6 +247,8 @@ class TaskService:
|
||||||
"processed_files": upload_task.processed_files,
|
"processed_files": upload_task.processed_files,
|
||||||
"successful_files": upload_task.successful_files,
|
"successful_files": upload_task.successful_files,
|
||||||
"failed_files": upload_task.failed_files,
|
"failed_files": upload_task.failed_files,
|
||||||
|
"running_files": running_files_count,
|
||||||
|
"pending_files": pending_files_count,
|
||||||
"created_at": upload_task.created_at,
|
"created_at": upload_task.created_at,
|
||||||
"updated_at": upload_task.updated_at,
|
"updated_at": upload_task.updated_at,
|
||||||
"duration_seconds": upload_task.duration_seconds,
|
"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():
|
for task_id, upload_task in self.task_store[store_user_id].items():
|
||||||
if task_id in tasks_by_id:
|
if task_id in tasks_by_id:
|
||||||
continue
|
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] = {
|
tasks_by_id[task_id] = {
|
||||||
"task_id": upload_task.task_id,
|
"task_id": upload_task.task_id,
|
||||||
"status": upload_task.status.value,
|
"status": upload_task.status.value,
|
||||||
|
|
@ -266,6 +287,8 @@ class TaskService:
|
||||||
"processed_files": upload_task.processed_files,
|
"processed_files": upload_task.processed_files,
|
||||||
"successful_files": upload_task.successful_files,
|
"successful_files": upload_task.successful_files,
|
||||||
"failed_files": upload_task.failed_files,
|
"failed_files": upload_task.failed_files,
|
||||||
|
"running_files": running_files_count,
|
||||||
|
"pending_files": pending_files_count,
|
||||||
"created_at": upload_task.created_at,
|
"created_at": upload_task.created_at,
|
||||||
"updated_at": upload_task.updated_at,
|
"updated_at": upload_task.updated_at,
|
||||||
"duration_seconds": upload_task.duration_seconds,
|
"duration_seconds": upload_task.duration_seconds,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue