From 9f7a73e1491e60fca356099e7ffe33872c0cecd5 Mon Sep 17 00:00:00 2001 From: mhmmdafif Date: Thu, 18 Dec 2025 15:18:20 +0700 Subject: [PATCH] add: plant sub section name, device, brand name in detail notification --- db/notification_error.db.js | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/db/notification_error.db.js b/db/notification_error.db.js index 2ec1500..7648683 100644 --- a/db/notification_error.db.js +++ b/db/notification_error.db.js @@ -14,8 +14,28 @@ const InsertNotificationErrorDb = async (store) => { const getNotificationByIdDb = async (id) => { const queryText = ` SELECT - a.* + a.*, + b.plant_sub_section_id, + c.plant_sub_section_name, + d.device_code, + d.device_name, + d.device_location, + e.brand_name + FROM notification_error a + + LEFT JOIN m_tags b + ON a.error_chanel = b.tag_number + + LEFT JOIN m_plant_sub_section c + ON b.plant_sub_section_id = c.plant_sub_section_id + + LEFT JOIN m_device d + ON b.device_id = d.device_id AND d.deleted_at IS NULL + + LEFT JOIN m_brands e + ON d.brand_id = e.brand_id AND d.deleted_at IS NULL + WHERE a.notification_error_id = $1 AND a.deleted_at IS NULL `; const result = await pool.query(queryText, [id]);