From b5d2de8edc35811f4cc207ccfbb4bd7ee1c0bfc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa=20Aubert?= Date: Wed, 6 Sep 2017 16:49:00 +0200 Subject: [PATCH] Do not use _.omit() --- lib/cartodb/models/dataview/histogram.js | 29 ++++++++++++++---------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/lib/cartodb/models/dataview/histogram.js b/lib/cartodb/models/dataview/histogram.js index 8624efc5..3d758b17 100644 --- a/lib/cartodb/models/dataview/histogram.js +++ b/lib/cartodb/models/dataview/histogram.js @@ -624,18 +624,23 @@ module.exports = class Histogram extends BaseWidget { offset = this.getOffset(override); } - buckets = result.rows.map(function(row) { - return _.omit( - row, - 'bins_number', - 'bin_width', - 'nulls_count', - 'infinities_count', - 'nans_count', - 'avg_val', - 'timestamp_start' - ); - }); + // TODO: after applying strategy we could use specialized .format() + // in order to know what props we want to expose using destructuring assignment + + const blacklisted = [ + 'bins_number', + 'bin_width', + 'nulls_count', + 'infinities_count', + 'nans_count', + 'avg_val', + 'timestamp_start' + ]; + + buckets = result.rows.map(row => Object.keys(row) + .filter((key) => blacklisted.indexOf(key) < 0) + .reduce((newObj, key) => Object.assign(newObj, { [key]: row[key] }), {}) + ); } return {