feat: implement reminder functionality and enhance notification service with logging
This commit is contained in:
@@ -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
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user