feat(task-status): enhance task status change handling to reset manual progress

- Added logic to reset manual_progress to FALSE when a task transitions from "done" to "todo" or "doing", allowing for accurate progress recalculation based on subtasks.
- Improved logging for task status changes to provide better insights into task management actions.
- Ensured parent task progress updates are triggered appropriately for subtasks during status changes.
This commit is contained in:
shancds
2025-07-01 10:18:56 +05:30
parent c048085c8a
commit e5ff036d81

View File

@@ -88,6 +88,23 @@ export async function on_task_status_change(_io: Server, socket: Socket, data?:
}, 100);
}
}
} else {
// Task is moving from "done" to "todo" or "doing" - reset manual_progress to FALSE
// so progress can be recalculated based on subtasks
await db.query(`
UPDATE tasks
SET manual_progress = FALSE
WHERE id = $1
`, [body.task_id]);
log(`Task ${body.task_id} moved from done status - manual_progress reset to FALSE`, null);
// If this is a subtask, update parent task progress
if (body.parent_task) {
setTimeout(() => {
socket.emit(SocketEvents.GET_TASK_PROGRESS.toString(), body.parent_task);
}, 100);
}
}
const info = await TasksControllerV2.getTaskCompleteRatio(body.parent_task || body.task_id);