diff --git a/controller/Errorlog/index.js b/controller/Errorlog/index.js index 22d62c8..5c52825 100644 --- a/controller/Errorlog/index.js +++ b/controller/Errorlog/index.js @@ -4,7 +4,7 @@ const { getCurrentDateTime } = require("../helper"); function errorLogStatus(error = null, funName = null) { let query = `INSERT INTO providentialadvisory.dbo.User_log (client_code, request, status, response, created_date, created_by, api_name, Open_Close_Status, IPAddress, DeviceId, [Source], Header) -VALUES('23232323', '${error}', 0, '', '${getCurrentDateTime()}', '', '${funName}', 0, '', '', '', '')`; +VALUES('', '${(error).toString()}', ${0}, '', '${getCurrentDateTime()}', '', '${funName}', ${0}, '', '', '', '')`; return db.sequelize.query(query, { type: db.sequelize.QueryTypes.INSERT }); } diff --git a/controller/getInvestmentSummary/index.js b/controller/getInvestmentSummary/index.js index 9c3f97a..05de4cf 100644 --- a/controller/getInvestmentSummary/index.js +++ b/controller/getInvestmentSummary/index.js @@ -26,7 +26,7 @@ function getHashCode(req) { const fetchAllInvestorId = async (sendId) => { let data = JSON.parse(sendId) - for (let i = 0; i < data.length; i++) { + for (let i = 0; i < data?.length; i++) { await createLiquiloanInvestor(data[i].investor_id, i) } } @@ -67,14 +67,13 @@ const createLiquiloanInvestor = (investor_id, index) => { if (currentData) { getUrlAndStore(currentData); } - console.log(index, "investor_id-->", investor_id, "currentData-->", currentData.length, "pastData-->", pastData.length) }); } const getUrlAndStore = async (callsData) => { try { let summary = [] - for (let i = 0; i < callsData.length; i++) { + for (let i = 0; i < callsData?.length; i++) { let checkTrnId = await getInvSummaryIdQuery(callsData[i].request_id); if (checkTrnId == 0) { let record = {}; @@ -121,7 +120,6 @@ const getUrlAndStore = async (callsData) => { last_updatedAt: getCurrentDateTime() } - console.log("WWWWWWWWWWWWR", record); await db.investorSummary.update(record, { where: { request_id: record.request_id @@ -129,10 +127,10 @@ const getUrlAndStore = async (callsData) => { }); } } - if (summary.length) { + if (summary?.length) { await db.investorSummary.bulkCreate(summary); } - + console.log("Success getInvestment summary"); } catch (err) { errorLogStatus(err, "nodeJs_liquiloan_getUrlAndStore") diff --git a/utils/scheduler.js b/utils/scheduler.js index 90180d2..30adb17 100644 --- a/utils/scheduler.js +++ b/utils/scheduler.js @@ -1,25 +1,30 @@ 'use strict'; const cron = require('node-cron'); +const { fetchInvestorDetails } = require('../controller/getAllInvestor'); +const { getAllInvestorId } = require('../controller/getInvestmentSummary'); +const { getReqAndInvId } = require('../controller/getTransactionById'); const routineFetchAllInvestors = () => { cron.schedule(process.env.SCHEDULER_RULE_FETCH_ALL_INVESTOR, () => { - console.log("running scheduler"); - // recordingController.callExotelRecording(); + console.log("running scheduler routineFetchAllInvestors"); + fetchInvestorDetails() }) }; const routineGetInvestmentSummary = () => { cron.schedule(process.env.SCHEDULER_RULE_INVESTMENT_SUMMARY, () => { - console.log("running scheduler"); - // recordingController.callExotelRecording(); + console.log("running scheduler routineGetInvestmentSummary"); + getAllInvestorId() + }) }; const routineGetTransactionById = () => { cron.schedule(process.env.SCHEDULER_RULE_TRANS_ID, () => { - console.log("running scheduler"); - // recordingController.callExotelRecording(); + console.log("running scheduler routineGetTransactionById"); + getReqAndInvId() + }) };