From 67c62fc69b80352adb6de1dbcfbd06333558e95f Mon Sep 17 00:00:00 2001 From: chamiakJ Date: Tue, 20 May 2025 11:55:29 +0530 Subject: [PATCH] refactor(schedule): streamline organization working days update query - Simplified the SQL update query for organization working days by removing unnecessary line breaks and improving readability. - Adjusted the subquery to directly select organization IDs, enhancing clarity and maintainability. --- .../src/controllers/schedule-v2/schedule-controller.ts | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/worklenz-backend/src/controllers/schedule-v2/schedule-controller.ts b/worklenz-backend/src/controllers/schedule-v2/schedule-controller.ts index a008c06d..a81ec0d0 100644 --- a/worklenz-backend/src/controllers/schedule-v2/schedule-controller.ts +++ b/worklenz-backend/src/controllers/schedule-v2/schedule-controller.ts @@ -74,14 +74,9 @@ export default class ScheduleControllerV2 extends WorklenzControllerBase { .map(day => `${day.toLowerCase()} = ${workingDays.includes(day)}`) .join(", "); - const updateQuery = ` - UPDATE public.organization_working_days + const updateQuery = `UPDATE public.organization_working_days SET ${setClause}, updated_at = CURRENT_TIMESTAMP - WHERE organization_id IN ( - SELECT organization_id FROM organizations - WHERE user_id = $1 - ); - `; + WHERE organization_id IN (SELECT id FROM organizations WHERE user_id = $1);`; await db.query(updateQuery, [req.user?.owner_id]);