From ff40b14945174f10d7f694e018a107a61a8b3369 Mon Sep 17 00:00:00 2001 From: Bibek Bharati Das Date: Thu, 24 Nov 2022 17:05:43 +0530 Subject: [PATCH] 5 min schedule for staging added with a console to verify --- controller/createVNubanController.js | 8 +++++++- cronjob.js | 9 ++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/controller/createVNubanController.js b/controller/createVNubanController.js index c5d3c27..bd80355 100644 --- a/controller/createVNubanController.js +++ b/controller/createVNubanController.js @@ -172,7 +172,13 @@ const createVNuban = (req, res) => { preferredBanks: ["232"] }, champ) }) - res.status(200).json(champs); + + if (appConfig.ENVIRONMENT != 'production') { + console.log("vNuban creation started"); + } + if (req) { + res.status(200).json(champs); + } }) }; diff --git a/cronjob.js b/cronjob.js index f8c4716..883c3d7 100644 --- a/cronjob.js +++ b/cronjob.js @@ -1,6 +1,7 @@ import fetch from "node-fetch"; import schedule from "node-schedule"; import createVNuban from "./controller/createVNubanController.js"; +import appConfig from './configs/appConfig.js'; const postSlackMessage = async (message) => { @@ -100,7 +101,13 @@ const initCronJob = () => { const initVNubanCronJob = () => { //run between 9 AM WAT to 9 PM WAT except Sundays at interval of 2 hours // (minute, hour, day(month), month, day(week)) - const jobInterval = '0 9-21/2 * * 1-6' + let jobInterval = '0 9-21/2 * * 1-6'; + + if (appConfig.ENVIRONMENT != 'production') { + // In staging, run every 5 minutes + jobInterval = '*/5 * * * *'; + } + const job1 = schedule.scheduleJob(jobInterval, () => { try { createVNuban()