fix(reminder_monthly): fix loop blocking issue by scoping validation to device_id

This commit is contained in:
2026-06-11 15:43:13 +07:00
parent e0b227c9b8
commit da8cdcb705
3 changed files with 21 additions and 26 deletions

View File

@@ -255,23 +255,20 @@ const getReminderNotificationErrorByYearlyDb = async (errorCode, chanel, year) =
return result.recordset[0];
};
const getReminderNotificationErrorByMonthlyDb = async (errorCode, monthly) => {
const getReminderNotificationErrorByMonthlyDb = async (errorCode, monthly, deviceId) => {
const queryText = `
SELECT a.*
FROM notification_error a
WHERE a.error_code_id = $1
AND MONTH(a.created_at) = $2
AND a.message_error_issue LIKE 'reminder%'
AND a.message_error_issue LIKE '%device_id: ' + CAST($3 AS VARCHAR) + '%'
AND a.is_active = 1
AND a.deleted_at IS NULL
`;
const result = await pool.query(queryText, [errorCode, monthly]);
const result = await pool.query(queryText, [errorCode, monthly, deviceId]);
return result.recordset[0];
};
module.exports = {
getNotificationByIdDb,
getDeviceNotificationByIdDb,