fix: update notification error handling to include new update method and improve reminder deletion logic

This commit is contained in:
2026-05-03 19:26:51 +07:00
parent abbce10e32
commit acb084475d
5 changed files with 198 additions and 83 deletions

View File

@@ -20,7 +20,7 @@ const getNotificationByIdDb = async (id) => {
COALESCE(d.device_code, f.device_code) AS device_code,
COALESCE(d.device_name, f.device_name) AS device_name,
COALESCE(d.device_location, f.device_location) AS device_location,
COALESCE(d.listen_channel, f.listen_channel_reminder) AS listen_channel
COALESCE(d.listen_channel, f.listen_channel_reminder) AS listen_channel,
e.brand_name,
e.brand_id
@@ -199,6 +199,19 @@ const updateNotificationErrorDb = async (id, data) => {
return getNotificationByIdDb(id);
};
const updateNotificationErrorByChanelReminderDb = async (id, data) => {
const store = { ...data };
const whereData = { error_chanel: id };
const { query: queryText, values } = pool.buildDynamicUpdate(
"notification_error",
store,
whereData
);
return await pool.query(`${queryText} AND deleted_at IS NULL`, values);
};
const getUsersNotificationErrorDb = async (id) => {
const queryText = `
SELECT
@@ -234,6 +247,7 @@ const getReminderNotificationErrorByYearlyDb = async (errorCode, chanel, year) =
AND a.error_chanel = $2
AND YEAR(a.created_at) = $3
AND a.message_error_issue LIKE 'reminder%'
AND a.is_active = 1
AND a.deleted_at IS NULL
`;
@@ -249,6 +263,7 @@ module.exports = {
updateNotificationErrorDb,
getUsersNotificationErrorDb,
getDeviceChannelReminder,
getReminderNotificationErrorByYearlyDb
getReminderNotificationErrorByYearlyDb,
updateNotificationErrorByChanelReminderDb
};