repair: get all notification
This commit is contained in:
@@ -16,23 +16,26 @@ const InsertNotificationErrorDb = async () => {
|
||||
1 AS is_delivered,
|
||||
0 AS is_read,
|
||||
1 AS is_send,
|
||||
|
||||
CONCAT(
|
||||
COALESCE(b.error_code_description, '-'),
|
||||
' pada ',
|
||||
COALESCE(d.plant_sub_section_name, '-'),
|
||||
COALESCE(d.device_name, '-'),
|
||||
'. Pengecekan potensi kerusakan dibutuhkan'
|
||||
) AS message_error_issue
|
||||
|
||||
FROM brand_code b
|
||||
|
||||
CROSS JOIN m_plant_sub_section d
|
||||
LEFT JOIN notification_error a
|
||||
ON a.error_code_id = b.error_code_id
|
||||
AND a.deleted_at IS NULL
|
||||
|
||||
LEFT JOIN notification_error ne
|
||||
ON ne.error_code_id = b.error_code_id
|
||||
AND ne.deleted_at IS NULL
|
||||
LEFT JOIN m_device d
|
||||
ON b.brand_id = d.brand_id
|
||||
AND d.deleted_at IS NULL
|
||||
|
||||
WHERE b.deleted_at IS NULL
|
||||
AND d.deleted_at IS NULL
|
||||
AND ne.notification_error_id IS NULL
|
||||
AND a.notification_error_id IS NULL;
|
||||
`;
|
||||
|
||||
await pool.query(insertQuery);
|
||||
@@ -43,7 +46,6 @@ const InsertNotificationErrorDb = async () => {
|
||||
const getAllNotificationDb = async (searchParams = {}) => {
|
||||
let queryParams = [];
|
||||
|
||||
// Tambahkan data baru jika belum ada
|
||||
await InsertNotificationErrorDb();
|
||||
|
||||
if (searchParams.limit) {
|
||||
@@ -84,18 +86,29 @@ const getAllNotificationDb = async (searchParams = {}) => {
|
||||
SELECT
|
||||
COUNT(*) OVER() AS total_data,
|
||||
|
||||
a.*,
|
||||
a.notification_error_id,
|
||||
a.error_code_id,
|
||||
a.message_error_issue,
|
||||
a.is_send,
|
||||
a.is_delivered,
|
||||
a.is_read,
|
||||
a.is_active,
|
||||
|
||||
b.error_code,
|
||||
b.error_code_name,
|
||||
b.created_at,
|
||||
|
||||
c.solution_name,
|
||||
c.type_solution,
|
||||
c.path_solution,
|
||||
|
||||
d.plant_sub_section_name,
|
||||
e.device_location
|
||||
d.device_name,
|
||||
d.device_location,
|
||||
|
||||
COALESCE(d.device_name, '') + ' - ' + COALESCE(b.error_code_name, '') AS device_name_error
|
||||
|
||||
FROM notification_error a
|
||||
|
||||
LEFT JOIN brand_code b
|
||||
ON a.error_code_id = b.error_code_id
|
||||
AND b.deleted_at IS NULL
|
||||
@@ -104,9 +117,9 @@ const getAllNotificationDb = async (searchParams = {}) => {
|
||||
ON b.error_code_id = c.error_code_id
|
||||
AND c.deleted_at IS NULL
|
||||
|
||||
CROSS JOIN m_plant_sub_section d
|
||||
|
||||
CROSS JOIN m_device e
|
||||
LEFT JOIN m_device d
|
||||
ON b.brand_id = d.brand_id
|
||||
AND d.deleted_at IS NULL
|
||||
|
||||
WHERE a.deleted_at IS NULL
|
||||
${
|
||||
|
||||
Reference in New Issue
Block a user