feat: implement reminder functionality and enhance notification service with logging

This commit is contained in:
2026-04-29 15:32:03 +07:00
parent 51f4ea2bff
commit a2a64a972f
8 changed files with 443 additions and 9 deletions

View File

@@ -61,6 +61,25 @@ const getDeviceNotificationByIdDb = async (chanel_id) => {
return result.recordset[0];
};
const getDeviceChannelReminder = async (chanel_reminder) => {
const queryText = `
SELECT
brand_id,
device_code,
device_name,
device_location,
listen_channel,
listen_channel_reminder,
reminder_at,
FROM m_device
WHERE listen_channel_reminder = $1
AND deleted_at IS NULL
`;
const result = await pool.query(queryText, [chanel_reminder]);
return result.recordset[0];
};
const getAllNotificationDb = async (searchParams = {}) => {
let queryParams = [];
@@ -202,12 +221,31 @@ const getUsersNotificationErrorDb = async (id) => {
return result.recordset;
};
const getReminderNotificationErrorByYearlyDb = async (errorCode, chanel, year) => {
const queryText = `
SELECT a.*
FROM notification_error a
WHERE a.error_code_id = $1
AND a.error_chanel = $2
AND YEAR(a.created_at) = $3
AND a.message_error_issue LIKE 'reminder%'
AND a.deleted_at IS NULL
`;
const result = await pool.query(queryText, [errorCode, chanel, year]);
return result.recordset[0];
};
module.exports = {
getNotificationByIdDb,
getDeviceNotificationByIdDb,
getAllNotificationDb,
InsertNotificationErrorDb,
updateNotificationErrorDb,
getUsersNotificationErrorDb
getUsersNotificationErrorDb,
getDeviceChannelReminder,
getReminderNotificationErrorByYearlyDb
};