From a674601e115eb8c2c2e7998a2a9b1cf79ae1ddc9 Mon Sep 17 00:00:00 2001 From: Vikas Agarwal Date: Wed, 18 Mar 2020 12:20:07 +0530 Subject: [PATCH 1/4] Added debug statements --- src/events/projects/index.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/events/projects/index.js b/src/events/projects/index.js index ab53c704..f089070d 100644 --- a/src/events/projects/index.js +++ b/src/events/projects/index.js @@ -172,7 +172,9 @@ async function projectUpdatedKafkaHandler(app, topic, payload) { // first get the existing document and than merge the updated changes and save the new document try { const doc = await eClient.get({ index: ES_PROJECT_INDEX, type: ES_PROJECT_TYPE, id: previousValue.id }); + app.logger.debug(doc, 'Received project from ES'); const merged = _.merge(doc._source, project.get({ plain: true })); // eslint-disable-line no-underscore-dangle + app.logger.debug(merged, 'Merged project'); // update the merged document await eClient.update({ index: ES_PROJECT_INDEX, @@ -182,6 +184,7 @@ async function projectUpdatedKafkaHandler(app, topic, payload) { doc: merged, }, }); + app.logger.debug(`Succesfully updated project document in ES (projectId: ${previousValue.id})`); } catch (error) { throw Error(`failed to updated project document in elasitcsearch index (projectId: ${previousValue.id})` + `. Details: '${error}'.`); From ea0cd366d3b8a79878e1eb2e65136ae0e3f78d5e Mon Sep 17 00:00:00 2001 From: Vikas Agarwal Date: Wed, 18 Mar 2020 12:37:05 +0530 Subject: [PATCH 2/4] Used console logs, somehow logger is null for the Kafka handler --- src/events/projects/index.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/events/projects/index.js b/src/events/projects/index.js index f089070d..b94da346 100644 --- a/src/events/projects/index.js +++ b/src/events/projects/index.js @@ -172,9 +172,9 @@ async function projectUpdatedKafkaHandler(app, topic, payload) { // first get the existing document and than merge the updated changes and save the new document try { const doc = await eClient.get({ index: ES_PROJECT_INDEX, type: ES_PROJECT_TYPE, id: previousValue.id }); - app.logger.debug(doc, 'Received project from ES'); + console.log(doc, 'Received project from ES'); const merged = _.merge(doc._source, project.get({ plain: true })); // eslint-disable-line no-underscore-dangle - app.logger.debug(merged, 'Merged project'); + console.log(merged, 'Merged project'); // update the merged document await eClient.update({ index: ES_PROJECT_INDEX, @@ -184,7 +184,7 @@ async function projectUpdatedKafkaHandler(app, topic, payload) { doc: merged, }, }); - app.logger.debug(`Succesfully updated project document in ES (projectId: ${previousValue.id})`); + console.log(`Succesfully updated project document in ES (projectId: ${previousValue.id})`); } catch (error) { throw Error(`failed to updated project document in elasitcsearch index (projectId: ${previousValue.id})` + `. Details: '${error}'.`); From b1abb51c0c17c6e74c270e39e884fa0e0f9422f4 Mon Sep 17 00:00:00 2001 From: Vikas Agarwal Date: Wed, 18 Mar 2020 14:55:28 +0530 Subject: [PATCH 3/4] Fixed path of data in ES response --- src/events/projects/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/events/projects/index.js b/src/events/projects/index.js index b94da346..28044a51 100644 --- a/src/events/projects/index.js +++ b/src/events/projects/index.js @@ -172,7 +172,7 @@ async function projectUpdatedKafkaHandler(app, topic, payload) { // first get the existing document and than merge the updated changes and save the new document try { const doc = await eClient.get({ index: ES_PROJECT_INDEX, type: ES_PROJECT_TYPE, id: previousValue.id }); - console.log(doc, 'Received project from ES'); + console.log(doc._source, 'Received project from ES'); const merged = _.merge(doc._source, project.get({ plain: true })); // eslint-disable-line no-underscore-dangle console.log(merged, 'Merged project'); // update the merged document From 256cb7738320b9ca7b441b9affd10ddcda5c7224 Mon Sep 17 00:00:00 2001 From: Vikas Agarwal Date: Wed, 18 Mar 2020 14:58:35 +0530 Subject: [PATCH 4/4] Lint fix --- src/events/projects/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/events/projects/index.js b/src/events/projects/index.js index 28044a51..df934bcf 100644 --- a/src/events/projects/index.js +++ b/src/events/projects/index.js @@ -172,7 +172,7 @@ async function projectUpdatedKafkaHandler(app, topic, payload) { // first get the existing document and than merge the updated changes and save the new document try { const doc = await eClient.get({ index: ES_PROJECT_INDEX, type: ES_PROJECT_TYPE, id: previousValue.id }); - console.log(doc._source, 'Received project from ES'); + console.log(doc._source, 'Received project from ES');// eslint-disable-line no-underscore-dangle const merged = _.merge(doc._source, project.get({ plain: true })); // eslint-disable-line no-underscore-dangle console.log(merged, 'Merged project'); // update the merged document