From 5ba9a2fe574b697620b5b0de3a34e6455b3dc77e Mon Sep 17 00:00:00 2001 From: Priyanka Pradeep Date: Tue, 19 Oct 2021 13:35:07 +0530 Subject: [PATCH] remove es --- .env.sample | 5 - config/db/elasticSearch.js | 68 ++--- config/index.js | 8 +- envVariables.js | 32 +-- generics/helpers/elasticSearch.js | 206 +++++++------- healthCheck/elastic-search.js | 32 --- healthCheck/healthCheckService.js | 9 - module/entities/helper.js | 428 +++++++++++++++--------------- module/userExtension/helper.js | 102 +++---- package.json | 1 - 10 files changed, 422 insertions(+), 469 deletions(-) diff --git a/.env.sample b/.env.sample index ca15cde5..82aba6e4 100644 --- a/.env.sample +++ b/.env.sample @@ -18,11 +18,6 @@ INCOMPLETE_SURVEY_SUBMISSION_TOPIC = "dev.sl.incomplete.survey.raw" KAFKA_GROUP_ID = "survey" // Kafka consumer group for ML Survey Service IMPROVEMENT_PROJECT_SUBMISSION_TOPIC = "dev.sl.improvement.project.submission" // Kafka topic name for pushing project submission related data -# Elastic search configurations -ELASTICSEARCH_COMMUNICATIONS_ON_OFF = "ON" // Elastic search enable/disable flag E.g. ON/OFF -ELASTICSEARCH_HOST_URL = "http://127.0.0.1:9200" // Elastic search host url -ELASTIC_SEARCH_SNIFF_ON_START = true/false // Flag to obtain ES Nodes list at the time of connection e.g. true/false -ELASTICSEARCH_ENTITIES_INDEX = "entities" // Elastic search index name for storing entity data # ML Core Service ML_CORE_SERVICE_URL = "http://ml-core-service:3000" // ML Core Service URL diff --git a/config/db/elasticSearch.js b/config/db/elasticSearch.js index 28fe284b..dc76d605 100644 --- a/config/db/elasticSearch.js +++ b/config/db/elasticSearch.js @@ -7,37 +7,37 @@ //dependencies -const { Client : esClient } = require('@elastic/elasticsearch'); - -/** - * Elastic search connection. - * @function - * @name connect - * @return {Object} elastic search client - */ - -var connect = function () { - - const elasticSearchClient = new esClient({ - node : process.env.ELASTICSEARCH_HOST_URL, - maxRetries : 5, - requestTimeout : 60000, - sniffOnStart : process.env.ELASTIC_SEARCH_SNIFF_ON_START - }); - - elasticSearchClient.ping({ - }, function (error) { - if (error) { - console.log('Elasticsearch cluster is down!'); - } else { - console.log('Elasticsearch connection established.'); - } - }); - - return { - client : elasticSearchClient - }; - -}; - -module.exports = connect; +// const { Client : esClient } = require('@elastic/elasticsearch'); + +// /** +// * Elastic search connection. +// * @function +// * @name connect +// * @return {Object} elastic search client +// */ + +// var connect = function () { + +// const elasticSearchClient = new esClient({ +// node : process.env.ELASTICSEARCH_HOST_URL, +// maxRetries : 5, +// requestTimeout : 60000, +// sniffOnStart : process.env.ELASTIC_SEARCH_SNIFF_ON_START +// }); + +// elasticSearchClient.ping({ +// }, function (error) { +// if (error) { +// console.log('Elasticsearch cluster is down!'); +// } else { +// console.log('Elasticsearch connection established.'); +// } +// }); + +// return { +// client : elasticSearchClient +// }; + +// }; + +// module.exports = connect; diff --git a/config/index.js b/config/index.js index 37bf9a47..0b875236 100644 --- a/config/index.js +++ b/config/index.js @@ -26,9 +26,9 @@ let db_connect = function() { * @name elasticsearch_connect */ -let elasticsearch_connect = function () { - global.elasticsearch = require("./db/elasticSearch")(); -}; +// let elasticsearch_connect = function () { +// global.elasticsearch = require("./db/elasticSearch")(); +// }; /** * Kafka connection information. @@ -49,6 +49,6 @@ const configuration = { db_connect(); kafka_connect(); -elasticsearch_connect(); +// elasticsearch_connect(); module.exports = configuration; diff --git a/envVariables.js b/envVariables.js index 28e60b26..d70d3442 100644 --- a/envVariables.js +++ b/envVariables.js @@ -58,18 +58,18 @@ let enviromentVariables = { "message" : "OFF/TOPIC_NAME", "optional" : false }, - "ELASTICSEARCH_COMMUNICATIONS_ON_OFF" : { - "message" : "Enable/Disable elastic search communications", - "optional" : false - }, - "ELASTICSEARCH_HOST_URL" : { - "message" : "Required elastic search host", - "optional" : false - }, - "ELASTICSEARCH_ENTITIES_INDEX" : { - "message" : "Required entities index", - "optional" : false - }, + // "ELASTICSEARCH_COMMUNICATIONS_ON_OFF" : { + // "message" : "Enable/Disable elastic search communications", + // "optional" : false + // }, + // "ELASTICSEARCH_HOST_URL" : { + // "message" : "Required elastic search host", + // "optional" : false + // }, + // "ELASTICSEARCH_ENTITIES_INDEX" : { + // "message" : "Required entities index", + // "optional" : false + // }, "ML_CORE_SERVICE_URL" : { "message" : "Required core service url", "optional" : false @@ -82,10 +82,10 @@ let enviromentVariables = { "message" : "Required keycloak public key path", "optional" : false }, - "ELASTIC_SEARCH_SNIFF_ON_START" : { - "message" : "Elastic search sniff on start", - "optional" : false - }, + // "ELASTIC_SEARCH_SNIFF_ON_START" : { + // "message" : "Elastic search sniff on start", + // "optional" : false + // }, "DISABLE_LEARNER_SERVICE_ON_OFF": { "message" : "Disable learner service on/off", "default": "ON" diff --git a/generics/helpers/elasticSearch.js b/generics/helpers/elasticSearch.js index fb81be3b..aea923e5 100644 --- a/generics/helpers/elasticSearch.js +++ b/generics/helpers/elasticSearch.js @@ -1,103 +1,103 @@ -/** - * name : elasticSearch.js - * author : Aman Jung Karki - * created-date : 11-Jun-2020 - * Description : elastic search common functionality - */ - -/** - * Get user data - * @function - * @name get - * @param {String} id - a unique document id - * @param {String} index - elastic search index - * @param {String} type - elastic search type - * @returns {Object} Get user data. -*/ - -var get = function ( - id = "", - index = "", - type = "" -) { - - return new Promise(async function (resolve, reject) { - try { - - if (id == "") { - throw new Error("ID is required"); - } - - if (index == "") { - throw new Error("Index is required"); - } - - const result = await elasticsearch.client.get({ - id: id, - index: index - }, { - ignore: [httpStatusCode["not_found"].status], - maxRetries: 3 - }); - - return resolve(result); - - } catch (error) { - return reject(error); - } - }) -}; - -/** - * Create or update based on user data. - * @function - * @name createOrUpdate - * @param {String} id - a unique document id - * @param {String} index - elastic search index - * @param {String} data - requested data - * @returns {Object} created or updated user data. -*/ - -var createOrUpdate = function ( - id = "", - index = "", - data = "" -) { - - return new Promise(async function (resolve, reject) { - try { - - if (id == "") { - throw new Error("ID is required"); - } - - if (index == "") { - throw new Error("Index is required"); - } - - if (Object.keys(data).length == 0) { - throw new Error("Data is required"); - } - - let result = - await elasticsearch.client.update({ - id : id, - index : index, - body : { - doc : data , - doc_as_upsert : true - } - }); - - return resolve(result); - - } catch (error) { - return reject(error); - } - }) -}; - -module.exports = { - get : get, - createOrUpdate : createOrUpdate -}; \ No newline at end of file +// /** +// * name : elasticSearch.js +// * author : Aman Jung Karki +// * created-date : 11-Jun-2020 +// * Description : elastic search common functionality +// */ + +// /** +// * Get user data +// * @function +// * @name get +// * @param {String} id - a unique document id +// * @param {String} index - elastic search index +// * @param {String} type - elastic search type +// * @returns {Object} Get user data. +// */ + +// var get = function ( +// id = "", +// index = "", +// type = "" +// ) { + +// return new Promise(async function (resolve, reject) { +// try { + +// if (id == "") { +// throw new Error("ID is required"); +// } + +// if (index == "") { +// throw new Error("Index is required"); +// } + +// const result = await elasticsearch.client.get({ +// id: id, +// index: index +// }, { +// ignore: [httpStatusCode["not_found"].status], +// maxRetries: 3 +// }); + +// return resolve(result); + +// } catch (error) { +// return reject(error); +// } +// }) +// }; + +// * +// * Create or update based on user data. +// * @function +// * @name createOrUpdate +// * @param {String} id - a unique document id +// * @param {String} index - elastic search index +// * @param {String} data - requested data +// * @returns {Object} created or updated user data. + + +// var createOrUpdate = function ( +// id = "", +// index = "", +// data = "" +// ) { + +// return new Promise(async function (resolve, reject) { +// try { + +// if (id == "") { +// throw new Error("ID is required"); +// } + +// if (index == "") { +// throw new Error("Index is required"); +// } + +// if (Object.keys(data).length == 0) { +// throw new Error("Data is required"); +// } + +// let result = +// await elasticsearch.client.update({ +// id : id, +// index : index, +// body : { +// doc : data , +// doc_as_upsert : true +// } +// }); + +// return resolve(result); + +// } catch (error) { +// return reject(error); +// } +// }) +// }; + +// module.exports = { +// get : get, +// createOrUpdate : createOrUpdate +// }; \ No newline at end of file diff --git a/healthCheck/elastic-search.js b/healthCheck/elastic-search.js index 288216cd..e69de29b 100644 --- a/healthCheck/elastic-search.js +++ b/healthCheck/elastic-search.js @@ -1,32 +0,0 @@ -/** - * name : elastic-search.js. - * author : Aman Karki. - * created-date : 02-Feb-2021. - * Description : Elastic Search health check. -*/ - -// Dependencies - -const { Client : esClient } = require('@elastic/elasticsearch'); - -function health_check() { - return new Promise( async (resolve,reject) => { - - const elasticSearchClient = new esClient({ - node: process.env.ELASTICSEARCH_HOST_URL - }); - - elasticSearchClient.ping({ - }, function (error) { - if (error) { - return resolve(false); - } else { - return resolve(true); - } - }); - }) -} - -module.exports = { - health_check : health_check -} \ No newline at end of file diff --git a/healthCheck/healthCheckService.js b/healthCheck/healthCheckService.js index e95fdf2c..b6e1583c 100644 --- a/healthCheck/healthCheckService.js +++ b/healthCheck/healthCheckService.js @@ -10,7 +10,6 @@ const { v1 : uuidv1 } = require('uuid'); const kendraHealthCheck = require("./kendra"); const mongodbHealthCheck = require("./mongodb"); const kafkaHealthCheck = require("./kafka"); -const elasticSearchHealthCheck = require("./elastic-search"); const improvementHealthCheck = require("./improvement-project"); const obj = { @@ -29,11 +28,6 @@ const obj = { FAILED_CODE: 'KENDRA_SERVICE_HEALTH_FAILED', FAILED_MESSAGE: 'Kendra service is not healthy' }, - ELASTIC_SEARCH : { - NAME: 'ElasticSearch.db', - FAILED_CODE: 'ELASTIC_SEARCH_HEALTH_FAILED', - FAILED_MESSAGE: 'Elastic search is not connected' - }, IMPROVEMENT_SERVICE: { NAME: 'improvementservice.api', FAILED_CODE: 'IMPROVEMENT_SERVICE_HEALTH_FAILED', @@ -49,15 +43,12 @@ let health_check = async function(req,res) { let mongodbConnection = await mongodbHealthCheck.health_check(); let kafkaConnection = await kafkaHealthCheck.health_check(); let kendraServiceStatus = await kendraHealthCheck.health_check(); - let elasticSearchConnection = await elasticSearchHealthCheck.health_check(); let improvementHealthCheckStatus = await improvementHealthCheck.health_check(); checks.push(checkResult("KAFKA",kafkaConnection)); checks.push(checkResult("MONGO_DB",mongodbConnection)); checks.push(checkResult("KENDRA_SERVICE",kendraServiceStatus)); checks.push(checkResult("IMPROVEMENT_SERVICE",improvementHealthCheckStatus)); - checks.push(checkResult("ELASTIC_SEARCH",elasticSearchConnection)); - checks.push(checkResult("ELASTIC_SEARCH",elasticSearchConnection)); let checkServices = checks.filter( check => check.healthy === false); diff --git a/module/entities/helper.js b/module/entities/helper.js index a0530792..2e9c0b15 100644 --- a/module/entities/helper.js +++ b/module/entities/helper.js @@ -7,7 +7,7 @@ // Dependencies const entityTypesHelper = require(MODULES_BASE_PATH + "/entityTypes/helper"); -const elasticSearch = require(ROOT_PATH + "/generics/helpers/elasticSearch"); +// const elasticSearch = require(ROOT_PATH + "/generics/helpers/elasticSearch"); const userRolesHelper = require(MODULES_BASE_PATH + "/userRoles/helper"); const FileStream = require(ROOT_PATH + "/generics/fileStream"); @@ -114,7 +114,7 @@ module.exports = class EntitiesHelper { throw messageConstants.apiResponses.ENTITY_INFORMATION_NOT_INSERTED; } - await this.pushEntitiesToElasticSearch(entities); + // await this.pushEntitiesToElasticSearch(entities); return resolve(entityData); @@ -633,7 +633,7 @@ module.exports = class EntitiesHelper { solutionsData[singleEntity._solutionId].newEntities.push(newEntity._id); } - await this.pushEntitiesToElasticSearch([singleEntity["_SYSTEM_ID"]]); + // await this.pushEntitiesToElasticSearch([singleEntity["_SYSTEM_ID"]]); return singleEntity; @@ -736,7 +736,7 @@ module.exports = class EntitiesHelper { singleEntity["UPDATE_STATUS"] = "No information to update."; } - await this.pushEntitiesToElasticSearch([singleEntity["_SYSTEM_ID"]]); + // await this.pushEntitiesToElasticSearch([singleEntity["_SYSTEM_ID"]]); return singleEntity; @@ -804,7 +804,7 @@ module.exports = class EntitiesHelper { })) } - await this.pushEntitiesToElasticSearch(entities); + // await this.pushEntitiesToElasticSearch(entities); this.entityMapProcessData = {}; @@ -1313,119 +1313,119 @@ module.exports = class EntitiesHelper { * @returns {Object} */ - static pushEntitiesToElasticSearch(entities = []) { - return new Promise(async (resolve, reject) => { - try { - - if (entities.length > 0) { - - let entityDocuments = await this.entityDocuments({ - _id: { - $in: entities - } - }, [ - "_id", - "metaInformation", - "entityType", - "entityTypeId", - "updatedAt", - "createdAt", - "allowedRoles", - "registryDetails" - ]); - - for (let entity = 0; entity < entityDocuments.length; entity++) { - - let entityDocument = entityDocuments[entity]; - - let telemetryEntities = []; - - let entityObj = { - _id: entityDocument._id, - entityType: entityDocument.entityType, - entityTypeId: entityDocument.entityTypeId, - updatedAt: entityDocument.updatedAt, - createdAt: entityDocument.createdAt, - registryDetails: entityDocument.registryDetails - } - - if( entityDocument.allowedRoles && entityDocument.allowedRoles.length > 0 ) { - entityObj["allowedRoles"] = entityDocument.allowedRoles; - } - - for (let metaData in entityDocument.metaInformation) { - entityObj[metaData] = entityDocument.metaInformation[metaData]; - } - - let telemetryObj = { - [`${entityObj.entityType}_name`]: entityObj.name, - [`${entityObj.entityType}_id`]: entityObj._id, - [`${entityObj.entityType}_externalId`]: entityObj.externalId - }; - - let relatedEntities = await this.relatedEntities( - entityObj._id, - entityObj.entityTypeId, - entityObj.entityType, - [ - "metaInformation.externalId", - "metaInformation.name", - "entityType", - "entityTypeId", - "_id" - ]) - - if (relatedEntities.length > 0) { - - relatedEntities = relatedEntities.map(entity => { - - telemetryObj[`${entity.entityType}_name`] = - entity.metaInformation.name; - - telemetryObj[`${entity.entityType}_id`] = - entity._id; - - telemetryObj[`${entity.entityType}_externalId`] = - entity.metaInformation.externalId; - - return { - name: entity.metaInformation.name, - externalId: entity.metaInformation.externalId, - entityType: entity.entityType, - entityTypeId: entity.entityTypeId, - _id: entity._id - } - }) - - entityObj["relatedEntities"] = relatedEntities; - } - - telemetryEntities.push(telemetryObj); - - entityObj["telemetry_entities"] = telemetryEntities; - - await elasticSearch.createOrUpdate( - entityObj._id, - process.env.ELASTICSEARCH_ENTITIES_INDEX, - { - data: entityObj - } - ); - - } - - } - - return resolve({ - success: true - }); - - } - catch (error) { - return reject(error); - } - }) - } + // static pushEntitiesToElasticSearch(entities = []) { + // return new Promise(async (resolve, reject) => { + // try { + + // if (entities.length > 0) { + + // let entityDocuments = await this.entityDocuments({ + // _id: { + // $in: entities + // } + // }, [ + // "_id", + // "metaInformation", + // "entityType", + // "entityTypeId", + // "updatedAt", + // "createdAt", + // "allowedRoles", + // "registryDetails" + // ]); + + // for (let entity = 0; entity < entityDocuments.length; entity++) { + + // let entityDocument = entityDocuments[entity]; + + // let telemetryEntities = []; + + // let entityObj = { + // _id: entityDocument._id, + // entityType: entityDocument.entityType, + // entityTypeId: entityDocument.entityTypeId, + // updatedAt: entityDocument.updatedAt, + // createdAt: entityDocument.createdAt, + // registryDetails: entityDocument.registryDetails + // } + + // if( entityDocument.allowedRoles && entityDocument.allowedRoles.length > 0 ) { + // entityObj["allowedRoles"] = entityDocument.allowedRoles; + // } + + // for (let metaData in entityDocument.metaInformation) { + // entityObj[metaData] = entityDocument.metaInformation[metaData]; + // } + + // let telemetryObj = { + // [`${entityObj.entityType}_name`]: entityObj.name, + // [`${entityObj.entityType}_id`]: entityObj._id, + // [`${entityObj.entityType}_externalId`]: entityObj.externalId + // }; + + // let relatedEntities = await this.relatedEntities( + // entityObj._id, + // entityObj.entityTypeId, + // entityObj.entityType, + // [ + // "metaInformation.externalId", + // "metaInformation.name", + // "entityType", + // "entityTypeId", + // "_id" + // ]) + + // if (relatedEntities.length > 0) { + + // relatedEntities = relatedEntities.map(entity => { + + // telemetryObj[`${entity.entityType}_name`] = + // entity.metaInformation.name; + + // telemetryObj[`${entity.entityType}_id`] = + // entity._id; + + // telemetryObj[`${entity.entityType}_externalId`] = + // entity.metaInformation.externalId; + + // return { + // name: entity.metaInformation.name, + // externalId: entity.metaInformation.externalId, + // entityType: entity.entityType, + // entityTypeId: entity.entityTypeId, + // _id: entity._id + // } + // }) + + // entityObj["relatedEntities"] = relatedEntities; + // } + + // telemetryEntities.push(telemetryObj); + + // entityObj["telemetry_entities"] = telemetryEntities; + + // await elasticSearch.createOrUpdate( + // entityObj._id, + // process.env.ELASTICSEARCH_ENTITIES_INDEX, + // { + // data: entityObj + // } + // ); + + // } + + // } + + // return resolve({ + // success: true + // }); + + // } + // catch (error) { + // return reject(error); + // } + // }) + // } /** @@ -1436,67 +1436,67 @@ module.exports = class EntitiesHelper { * @name userId - user id * @returns {Object} */ - static updateUserRolesInEntitiesElasticSearch(userRoles = [], userId = "") { - return new Promise(async (resolve, reject) => { - try { +// static updateUserRolesInEntitiesElasticSearch(userRoles = [], userId = "") { +// return new Promise(async (resolve, reject) => { +// try { - await Promise.all(userRoles.map( async role => { - await Promise.all(role.entities.map(async entity => { - - let entityDocument = await elasticSearch.get - ( - entity, - process.env.ELASTICSEARCH_ENTITIES_INDEX - ) +// await Promise.all(userRoles.map( async role => { +// await Promise.all(role.entities.map(async entity => { + +// let entityDocument = await elasticSearch.get +// ( +// entity, +// process.env.ELASTICSEARCH_ENTITIES_INDEX +// ) - if (entityDocument.statusCode == httpStatusCode.ok.status) { +// if (entityDocument.statusCode == httpStatusCode.ok.status) { - entityDocument = entityDocument.body["_source"].data; +// entityDocument = entityDocument.body["_source"].data; - if (!entityDocument.roles) { - entityDocument.roles = {}; - } +// if (!entityDocument.roles) { +// entityDocument.roles = {}; +// } - if (entityDocument.roles[role.code]) { - if (!entityDocument.roles[role.code].includes(userId)) { - entityDocument.roles[role.code].push(userId); - - await elasticSearch.createOrUpdate - ( - entity, - process.env.ELASTICSEARCH_ENTITIES_INDEX, - { - data: entityDocument - } - ) - } - } - else { - entityDocument.roles[role.code] = [userId]; - - await elasticSearch.createOrUpdate - ( - entity, - process.env.ELASTICSEARCH_ENTITIES_INDEX, - { - data: entityDocument - } - ) - } - } - })) - })) - - return resolve({ - success: true - }); - - } - catch (error) { - return reject(error); - } - }) -} +// if (entityDocument.roles[role.code]) { +// if (!entityDocument.roles[role.code].includes(userId)) { +// entityDocument.roles[role.code].push(userId); + +// await elasticSearch.createOrUpdate +// ( +// entity, +// process.env.ELASTICSEARCH_ENTITIES_INDEX, +// { +// data: entityDocument +// } +// ) +// } +// } +// else { +// entityDocument.roles[role.code] = [userId]; + +// await elasticSearch.createOrUpdate +// ( +// entity, +// process.env.ELASTICSEARCH_ENTITIES_INDEX, +// { +// data: entityDocument +// } +// ) +// } +// } +// })) +// })) + +// return resolve({ +// success: true +// }); + +// } +// catch (error) { +// return reject(error); +// } +// }) +// } /** @@ -1507,49 +1507,49 @@ module.exports = class EntitiesHelper { * @name role - role of user * @returns {Object} */ -static deleteUserRoleFromEntitiesElasticSearch(entityId = "", role = "", userId = "") { - return new Promise(async (resolve, reject) => { - try { +// static deleteUserRoleFromEntitiesElasticSearch(entityId = "", role = "", userId = "") { +// return new Promise(async (resolve, reject) => { +// try { - let entityDocument = await elasticSearch.get - ( - entityId, - process.env.ELASTICSEARCH_ENTITIES_INDEX - ) - - if (entityDocument.statusCode == httpStatusCode.ok.status) { - - entityDocument = entityDocument.body["_source"].data; - - if (entityDocument.roles && entityDocument.roles[role]) { - - let index = entityDocument.roles[role].indexOf(userId); - if (index > -1) { - entityDocument.roles[role].splice(index, 1); - - await elasticSearch.createOrUpdate - ( - entityId, - process.env.ELASTICSEARCH_ENTITIES_INDEX, - { - data: entityDocument - } - ) - } +// let entityDocument = await elasticSearch.get +// ( +// entityId, +// process.env.ELASTICSEARCH_ENTITIES_INDEX +// ) + +// if (entityDocument.statusCode == httpStatusCode.ok.status) { + +// entityDocument = entityDocument.body["_source"].data; + +// if (entityDocument.roles && entityDocument.roles[role]) { + +// let index = entityDocument.roles[role].indexOf(userId); +// if (index > -1) { +// entityDocument.roles[role].splice(index, 1); + +// await elasticSearch.createOrUpdate +// ( +// entityId, +// process.env.ELASTICSEARCH_ENTITIES_INDEX, +// { +// data: entityDocument +// } +// ) +// } - } - } +// } +// } - return resolve({ - success: true - }); +// return resolve({ +// success: true +// }); - } - catch (error) { - return reject(error); - } - }) -} +// } +// catch (error) { +// return reject(error); +// } +// }) +// } /** * Upload registry via csv. @@ -1730,7 +1730,7 @@ static deleteUserRoleFromEntitiesElasticSearch(entityId = "", role = "", userId singleCsvData["_SYSTEM_ID"] = entityUpdated._id; singleCsvData["STATUS"] = messageConstants.common.SUCCESS; - this.pushEntitiesToElasticSearch([entityUpdated._id]); + // this.pushEntitiesToElasticSearch([entityUpdated._id]); input.push(singleCsvData); } diff --git a/module/userExtension/helper.js b/module/userExtension/helper.js index db511558..840351ed 100644 --- a/module/userExtension/helper.js +++ b/module/userExtension/helper.js @@ -10,7 +10,7 @@ const userRolesHelper = require(MODULES_BASE_PATH + "/userRoles/helper"); const entityTypesHelper = require(MODULES_BASE_PATH + "/entityTypes/helper"); const entitiesHelper = require(MODULES_BASE_PATH + "/entities/helper"); const shikshalokamGenericHelper = require(ROOT_PATH + "/generics/helpers/shikshalokam"); -const elasticSearchData = require(ROOT_PATH + "/generics/helpers/elasticSearch"); +// const elasticSearchData = require(ROOT_PATH + "/generics/helpers/elasticSearch"); const programsHelper = require(MODULES_BASE_PATH + "/programs/helper"); /** @@ -922,61 +922,61 @@ module.exports = class UserExtensionHelper { * @returns {Object} */ - static pushUserToElasticSearch(userData, removeUserFromEntity= {}) { - return new Promise(async (resolve, reject) => { - try { - - let userInformation = _.pick(userData,[ - "_id", - "status", - "isDeleted", - "deleted", - "roles", - "userId", - "externalId", - "updatedBy", - "createdBy", - "updatedAt", - "createdAt" - ]); +// static pushUserToElasticSearch(userData, removeUserFromEntity= {}) { +// return new Promise(async (resolve, reject) => { +// try { + +// let userInformation = _.pick(userData,[ +// "_id", +// "status", +// "isDeleted", +// "deleted", +// "roles", +// "userId", +// "externalId", +// "updatedBy", +// "createdBy", +// "updatedAt", +// "createdAt" +// ]); - await elasticSearchData.createOrUpdate( - userData.userId, - process.env.ELASTICSEARCH_USER_EXTENSION_INDEX, - { - data : userInformation - } - ); - - if (userInformation.roles.length > 0) { - await entitiesHelper.updateUserRolesInEntitiesElasticSearch - ( - userInformation.roles, - userInformation.userId - ) - } +// await elasticSearchData.createOrUpdate( +// userData.userId, +// process.env.ELASTICSEARCH_USER_EXTENSION_INDEX, +// { +// data : userInformation +// } +// ); + +// if (userInformation.roles.length > 0) { +// await entitiesHelper.updateUserRolesInEntitiesElasticSearch +// ( +// userInformation.roles, +// userInformation.userId +// ) +// } - if (Object.keys(removeUserFromEntity).length > 0) { - await entitiesHelper.deleteUserRoleFromEntitiesElasticSearch - ( - removeUserFromEntity.entityId, - removeUserFromEntity.role, - userInformation.userId - ) - } - - return resolve({ - success : true - }); +// if (Object.keys(removeUserFromEntity).length > 0) { +// await entitiesHelper.deleteUserRoleFromEntitiesElasticSearch +// ( +// removeUserFromEntity.entityId, +// removeUserFromEntity.role, +// userInformation.userId +// ) +// } + +// return resolve({ +// success : true +// }); - } - catch(error) { - return reject(error); - } - }) +// } +// catch(error) { +// return reject(error); +// } +// }) - } +// } /** * Update userExtension document. diff --git a/package.json b/package.json index bdbe4763..29170d0a 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,6 @@ "author": "Akash Shah ", "license": "ISC", "dependencies": { - "@elastic/elasticsearch": "^7.7.1", "body-parser": "^1.18.2", "bunyan": "^1.8.12", "cache-manager": "^2.9.0",