Commit ab05a347df0072ae6ece59f0f829a5614737f208
1 parent
6369bc73bc
Exists in
master
Fix pemanggilan getMaxValuesForIndicator kosong
Showing 1 changed file with 8 additions and 2 deletions Side-by-side Diff
lib/redis-util.js
... | ... | @@ -270,11 +270,17 @@ const setMaxValueForIndicator = (product, val, xid) => new Promise((resolve) => |
270 | 270 | exports.setMaxValueForIndicator = setMaxValueForIndicator; |
271 | 271 | |
272 | 272 | const getMaxValuesForIndicator = (products, xid) => new Promise((resolve, reject) => { |
273 | - const keywords = products.map((item) => `${composeKeyword(item)}_MAX_VALUE`); | |
273 | + const keywords = (products || []).map((item) => `${composeKeyword(item)}_MAX_VALUE`); | |
274 | + | |
275 | + if (!keywords || !keywords.length) { | |
276 | + resolve([]); | |
277 | + return; | |
278 | + } | |
279 | + | |
274 | 280 | redisClient.mget(...keywords, (err, reply) => { |
275 | 281 | if (err) { |
276 | 282 | logger.warn(`63BE7706 ${MODULE_NAME}: Error on getting max values on redis`, { |
277 | - xid, eCode: err.code, eMessage: err.message, | |
283 | + xid, eCode: err.code, products, keywords, eMessage: err.message, | |
278 | 284 | }); |
279 | 285 | reject(err); |
280 | 286 | return; |