Commit d077430dfbd32c4f90f13f67e0e8fc68dc9a9a94
1 parent
0e90ae10a3
Exists in
master
perbaikan mongo
Showing 1 changed file with 16 additions and 7 deletions Side-by-side Diff
partner-cjk.js
... | ... | @@ -117,16 +117,9 @@ function pushResponseToMongoDb(task, response) { |
117 | 117 | if (!isMongoReady()) { return; } |
118 | 118 | |
119 | 119 | try { |
120 | - var lastResponse = {}; | |
121 | - | |
122 | - if (response.parsed && response.parsed.ciwaru) { | |
123 | - lastResponse = response.parsed.ciwaru; | |
124 | - } | |
125 | - | |
126 | 120 | mongodb.collection(config.mongodb.collection).updateOne( |
127 | 121 | {requestId: task.requestId}, |
128 | 122 | { |
129 | - lastResponse: lastResponse, | |
130 | 123 | $push: {responses: response} |
131 | 124 | }, |
132 | 125 | function(err, result) { |
... | ... | @@ -136,6 +129,22 @@ function pushResponseToMongoDb(task, response) { |
136 | 129 | } |
137 | 130 | } |
138 | 131 | ); |
132 | + | |
133 | + if (response.parsed && response.parsed.ciwaru) { | |
134 | + mongodb.collection(config.mongodb.collection).updateOne( | |
135 | + {requestId: task.requestId}, | |
136 | + { | |
137 | + lastResponse: response.parsed.ciwaru | |
138 | + }, | |
139 | + function(err, result) { | |
140 | + if (err) { | |
141 | + logger.warn('Error when updating last response to mongodb', {err: err, task: task, response: response}); | |
142 | + return; | |
143 | + } | |
144 | + } | |
145 | + ); | |
146 | + } | |
147 | + | |
139 | 148 | } |
140 | 149 | catch(err) { |
141 | 150 | logger.warn('Exception when pushing response to mongodb', {err: err, task: task, response: response}); |