fix(tasks-controller): update SQL queries to use template literals for projectId

- Modified SQL queries in TasksControllerV2 to use template literals for the projectId variable, enhancing readability and consistency in the code.
- Removed the parameterized query approach for projectId in the relevant sections of the code.
This commit is contained in:
chamiakJ
2025-05-14 19:17:39 +05:30
parent c52b223c59
commit c4837e7e5c

View File

@@ -843,7 +843,7 @@ export default class TasksControllerV2 extends TasksControllerBase {
-- First, reset manual_progress flag for all tasks that have subtasks within this project -- First, reset manual_progress flag for all tasks that have subtasks within this project
UPDATE tasks AS t UPDATE tasks AS t
SET manual_progress = FALSE SET manual_progress = FALSE
WHERE project_id = $1 WHERE project_id = '${projectId}'
AND EXISTS ( AND EXISTS (
SELECT 1 SELECT 1
FROM tasks FROM tasks
@@ -860,7 +860,7 @@ export default class TasksControllerV2 extends TasksControllerBase {
parent_task_id, parent_task_id,
0 AS level 0 AS level
FROM tasks FROM tasks
WHERE project_id = $1 WHERE project_id = '${projectId}'
AND NOT EXISTS ( AND NOT EXISTS (
SELECT 1 FROM tasks AS sub SELECT 1 FROM tasks AS sub
WHERE sub.parent_task_id = tasks.id WHERE sub.parent_task_id = tasks.id
@@ -888,12 +888,12 @@ export default class TasksControllerV2 extends TasksControllerBase {
ORDER BY level ORDER BY level
) AS ordered_tasks ) AS ordered_tasks
WHERE tasks.id = ordered_tasks.id WHERE tasks.id = ordered_tasks.id
AND tasks.project_id = $1 AND tasks.project_id = '${projectId}'
AND (manual_progress IS FALSE OR manual_progress IS NULL); AND (manual_progress IS FALSE OR manual_progress IS NULL);
END $$; END $$;
`; `;
const result = await db.query(query, [projectId]); const result = await db.query(query);
console.log(`Finished refreshing progress values for project ${projectId}`); console.log(`Finished refreshing progress values for project ${projectId}`);
} catch (error) { } catch (error) {
log_error('Error refreshing project task progress values', error); log_error('Error refreshing project task progress values', error);