@@ -45,7 +45,7 @@ function createSchema () {
4545 */
4646async function create ( message ) {
4747 // handle ES Update
48- async function updateDocPromise ( doc ) {
48+ async function updateDocPromise ( doc ) { // eslint-disable-line no-unused-vars
4949 const phases = _ . isArray ( doc . _source . phases ) ? doc . _source . phases : [ ]
5050 const existingPhaseIndex = _ . findIndex ( phases , p => p . id === message . id ) // if phase does not exists already
5151 if ( existingPhaseIndex === - 1 ) {
@@ -66,8 +66,14 @@ async function create (message) {
6666 return _ . assign ( doc . _source , { phases } )
6767 }
6868
69- await helper . updateProjectESPromise ( message . projectId , updateDocPromise )
70- logger . debug ( `Project phase created successfully in elasticsearch index, (projectPhaseId: ${ message . id } )` )
69+ // NOTE Disable indexing phases when create at the moment, as it's now being indexed inside Project Service.
70+ // It's because adding a phase may cause cascading updates of other phases and in such cases we are doing
71+ // one ES index call instead of multiple calls. Otherwise ES may fail with error `version conflict`.
72+ // This would be turned on back, as soon as we get rid of such cascading updates inside Project Service.
73+ //
74+ // await helper.updateProjectESPromise(message.projectId, updateDocPromise)
75+ // logger.debug(`Project phase created successfully in elasticsearch index, (projectPhaseId: ${message.id})`)
76+ logger . debug ( `TEMPORARY SKIPPED: Project phase created successfully in elasticsearch index, (projectPhaseId: ${ message . id } )` )
7177}
7278
7379create . schema = {
@@ -81,7 +87,7 @@ create.schema = {
8187 */
8288async function update ( message ) {
8389 // handle ES Update
84- async function updateDocPromise ( doc ) {
90+ async function updateDocPromise ( doc ) { // eslint-disable-line no-unused-vars
8591 const phases = _ . map ( doc . _source . phases , ( single ) => {
8692 if ( single . id === message . id ) {
8793 return _ . assign ( single , message )
@@ -91,8 +97,14 @@ async function update (message) {
9197 return _ . assign ( doc . _source , { phases } )
9298 }
9399
94- await helper . updateProjectESPromise ( message . projectId , updateDocPromise )
95- logger . debug ( `Project phase updated successfully in elasticsearch index, (projectPhaseId: ${ message . id } )` )
100+ // NOTE Disable indexing phases when update at the moment, as it's now being indexed inside Project Service.
101+ // It's because updating a phase may cause cascading updates of other phases and in such cases we are doing
102+ // one ES index call instead of multiple calls. Otherwise ES may fail with error `version conflict`.
103+ // This would be turned on back, as soon as we get rid of such cascading updates inside Project Service.
104+ //
105+ // await helper.updateProjectESPromise(message.projectId, updateDocPromise)
106+ // logger.debug(`Project phase updated successfully in elasticsearch index, (projectPhaseId: ${message.id})`)
107+ logger . debug ( `TEMPORARY SKIPPED: Project phase updated successfully in elasticsearch index, (projectPhaseId: ${ message . id } )` )
96108}
97109
98110update . schema = {
0 commit comments