From 761c54551b1beb61ddc422e46e64f5a1007cb5e3 Mon Sep 17 00:00:00 2001 From: Akhilesh Chandak Date: Wed, 13 Dec 2023 15:58:13 +0530 Subject: [PATCH] code fix --- controller/getInvestmentSumarry.js | 21 ++++++++++++--------- model/investorSummary.js | 3 ++- utils/db_config.js | 30 ------------------------------ 3 files changed, 14 insertions(+), 40 deletions(-) diff --git a/controller/getInvestmentSumarry.js b/controller/getInvestmentSumarry.js index ad62485..5cc344a 100644 --- a/controller/getInvestmentSumarry.js +++ b/controller/getInvestmentSumarry.js @@ -22,6 +22,9 @@ function getHashCode(req) { } + + + const createLiquiloanInvestor = () => { for (let i = 0; i < arrayGetList.length; i++) { @@ -49,13 +52,11 @@ const createLiquiloanInvestor = () => { const getUrlAndStore = async (body) => { try { const data = JSON.parse(body) - // console.log(data, "111111111111111111111111111111111111111111"); let callsData = data; - let calls = []; + let summary = [] // if (callsData.length) { - console.log(callsData.data.past_investments.length, "LDPDPLDPLDPLLPDPDLDLPDPLDPL"); + //console.log(callsData.data.past_investments.length, "LDPDPLDPLDPLLPDPDLDLPDPLDPL"); for (let i = 0; i < callsData.data.past_investments.length; i++) { - console.log(); let record = {}; record.transaction_id = callsData.data.past_investments[i].transaction_id, record.investor_id = callsData.data.past_investments[i].investor_id, @@ -89,14 +90,16 @@ const getUrlAndStore = async (body) => { record.withdrawable_balance = callsData.data.past_investments[i].withdrawable_balance, record.scheme_closed_date = callsData.data.past_investments[i].scheme_closed_date, record.request_id = callsData.data.past_investments[i].request_id, - record.source = callsData.data.past_investments[i].source + record.source = callsData.data.past_investments[i].source, + record.created_at = new Date() - calls.push(record); - console.log('calls---->', calls); - await db.P2P_Liquiloans_Inv_Summarys.bulkCreate(calls); - + summary.push(record); } + + console.log('calls---->', summary); + await db.investorSummary.bulkCreate(summary); + //} } catch (err) { console.log(err, "KDDODKODKODKODKODKODKO"); diff --git a/model/investorSummary.js b/model/investorSummary.js index 961714f..9a9e665 100644 --- a/model/investorSummary.js +++ b/model/investorSummary.js @@ -1,7 +1,7 @@ module.exports = function (sequelize, DataTypes) { const getInvestorSummary = sequelize.define('P2P_Liquiloans_Inv_Summarys', { - transaction_id: { type: DataTypes.INTEGER, allowNull: true}, + transaction_id: { type: DataTypes.INTEGER, allowNull: false, unique: true }, investor_id: { type: DataTypes.INTEGER, allowNull: true }, scheme_id: { type: DataTypes.INTEGER, allowNull: true }, investment_roi: { type: DataTypes.INTEGER, allowNull: true }, @@ -34,6 +34,7 @@ module.exports = function (sequelize, DataTypes) { scheme_closed_date: { type: DataTypes.STRING, allowNull: true }, request_id: { type: DataTypes.INTEGER, allowNull: true }, source: { type: DataTypes.STRING, allowNull: true }, + created_at: { type: DataTypes.STRING, allowNull: true }, }, { //freezeTableName: true, // Model tableName will be the same as the model name timestamps: false, diff --git a/utils/db_config.js b/utils/db_config.js index a8bdb8e..7dde667 100644 --- a/utils/db_config.js +++ b/utils/db_config.js @@ -44,33 +44,3 @@ db.investorSummary = require('../model/investorSummary')(sequelize, Sequelize); module.exports = db; - -/* -const sql = require('mssql') -const sqlConfig = { - user: 'BSeMF', - password: 'nivesh2017', - database: 'providentialadvisory', - server: 'ec2-13-235-204-185.ap-south-1.compute.amazonaws.com', - pool: { - max: 10, - min: 0, - idleTimeoutMillis: 30000 - }, - options: { - encrypt: true, // for azure - trustServerCertificate: true // change to true for local dev / self-signed certs - } -} - -const connection = async () => { - try { - console.log('ajksfkgjsafkksafkkfskf') - let con = await sql.connect(sqlConfig) - console.log('connection',con); - } catch (err) { - console.log(err); - } - }; - connection(); -*/