FIX: Ajustado status de completed para uso correto do banco de dados
This commit is contained in:
parent
53bdd1c5a5
commit
fa6931a5bb
@ -6,7 +6,7 @@ const runWatchdog = require('../../modules/watchdog/job/job')
|
||||
|
||||
logInfo('[CRON] 🐶 Watchdog cron iniciado')
|
||||
|
||||
cron.schedule('*/30 * * * *', async () => {
|
||||
cron.schedule('*/5 * * * *', async () => {
|
||||
logInfo('[CRON] 🐶 Watchdog executando verificação')
|
||||
|
||||
try {
|
||||
|
||||
@ -137,7 +137,7 @@ async function markNotificationsAsCompleted(hubsoftTicketIds, type = 'func') {
|
||||
|
||||
if (ids.length === 0) return;
|
||||
|
||||
const status = buildStatus('completed', type);
|
||||
const status = buildStatus('end', type);
|
||||
const query = `
|
||||
INSERT INTO watchdog_notifications (ticket_id, notified_at, status)
|
||||
SELECT
|
||||
@ -153,12 +153,11 @@ async function markNotificationsAsCompleted(hubsoftTicketIds, type = 'func') {
|
||||
try {
|
||||
await db.query(query, [ids, status]);
|
||||
} catch (error) {
|
||||
logError('[WATCHDOG][REPOSITORY] Erro ao marcar notificaÇÎÇæÇÎÇÝes como concluido', error);
|
||||
logError('[WATCHDOG][REPOSITORY] Erro ao marcar notificação como concluido', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
async function getPendingTicketsForNotification(type = 'func') {
|
||||
const status = buildStatus('pending', type);
|
||||
const query = `
|
||||
|
||||
@ -117,10 +117,6 @@ async function getTicketsClosedSince(thresholdDate) {
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
const mundialeUserId = process.env.HUBSOFT_MUNDIALE_USER_ID;
|
||||
|
||||
if (!mundialeUserId) {
|
||||
|
||||
@ -21,7 +21,7 @@ async function notifyAdmins({ sinceMinutes = 30 } = {}) {
|
||||
continue
|
||||
}
|
||||
|
||||
const isUpdated = await repository.checkTicketIsUpdated(glpiTicketId, sinceMinutes)
|
||||
const isUpdated = await repository.checkTicketIsUpdated(glpiTicketId, sinceMinutes)
|
||||
if (isUpdated) {
|
||||
logInfo(`[WATCHDOG] [ADM] Chamado ${hubsoftTicketId} atualizado no GLPI. Encerrando fluxo.`)
|
||||
await repository.markNotificationAsCompleted(hubsoftTicketId, 'func')
|
||||
|
||||
Loading…
Reference in New Issue
Block a user