fix: reminder monthly, and cron in reminder reminder monthly

This commit is contained in:
2026-06-24 19:33:23 +07:00
parent 8fd317083b
commit 55aa2f05c6
4 changed files with 353 additions and 137 deletions

View File

@@ -149,12 +149,23 @@ const getDeviceReminderMonthlyDb = async (id) => {
COALESCE(a.device_code, '') + ' - ' + COALESCE(a.device_name, '') AS device_code_name
FROM m_device a
LEFT JOIN m_brands b ON a.brand_id = b.brand_id
WHERE a.device_id = $1 AND a.deleted_at IS NULL AND a.reminder_at_monthly IS NOT NULL
WHERE a.device_id = $1 AND a.deleted_at IS NULL
`;
const result = await pool.query(queryText, [id]);
return result.recordset;
};
const updateDeviceReminderMonthlyDb = async (deviceId, reminderMonthly) => {
const queryText = `
UPDATE m_device
SET reminder_at_monthly = $1,
updated_at = CURRENT_TIMESTAMP
WHERE device_id = $2 AND deleted_at IS NULL
`;
await pool.query(queryText, [reminderMonthly, deviceId]);
return getDeviceByIdDb(deviceId);
};
const getDeviceReminderCustomDb = async (id) => {
const queryText = `
SELECT
@@ -193,4 +204,5 @@ module.exports = {
getDeviceReminderMonthlyDb,
getDeviceReminderCustomDb,
updateDeviceReminderCustomDb,
updateDeviceReminderMonthlyDb
};