21 lines
773 B
JavaScript
21 lines
773 B
JavaScript
// src/modules/watchdog/job/job.js
|
|
|
|
require('dotenv').config({ path: '.env.development' })
|
|
|
|
const { logError, logInfo } = require('../../../shared/utils/logger')
|
|
const { notifyCollaborators } = require('../services/notifyCollaborators.service.js')
|
|
const { notifyAdmins } = require('../services/notifyAdmins.service.js')
|
|
|
|
async function runWatchdog() {
|
|
const { sentCount: sentFunc } = await notifyCollaborators({ thresholdMinutes: 31 })
|
|
const { sentCount: sentAdm } = await notifyAdmins({ sinceMinutes: 30 })
|
|
|
|
logInfo(`[WATCHDOG] [JOB] Enviadas ${sentFunc} notificacoes para colaboradores e ${sentAdm} para ADM.`)
|
|
}
|
|
|
|
runWatchdog().catch((error) => {
|
|
logError('[WATCHDOG] [JOB] Erro ao executar o job do Watchdog', error)
|
|
})
|
|
|
|
module.exports = { runWatchdog }
|