From 3b6bf80ea478485d1f3ddf9e2ffb73cd104fd102 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Tue, 21 Jan 2014 21:45:25 +0100 Subject: [PATCH] removed more unused code --- src/app/components/kbn.js | 88 --------------------------------------- 1 file changed, 88 deletions(-) diff --git a/src/app/components/kbn.js b/src/app/components/kbn.js index 372424305d6..c6cd97df022 100644 --- a/src/app/components/kbn.js +++ b/src/app/components/kbn.js @@ -4,94 +4,6 @@ function($, _, moment) { var kbn = {}; - kbn.get_object_fields = function(obj) { - var field_array = []; - obj = kbn.flatten_json(obj._source); - for (var field in obj) { - field_array.push(field); - } - return field_array.sort(); - }; - - kbn.get_all_fields = function(data,flat) { - return _.uniq(_.without(_.reduce(data,function(memo,hit) { - return flat ? memo.concat(_.keys(kbn.flatten_json(hit._source))) : memo.concat(_.keys(hit._source)); - },[]),'$$hashkey')); - }; - - kbn.has_field = function(obj,field) { - var obj_fields = kbn.get_object_fields(obj); - if (_.inArray(obj_fields,field) < 0) { - return false; - } else { - return true; - } - }; - - kbn.get_related_fields = function(docs,field) { - var field_array = []; - _.each(docs, function(doc) { - var keys = _.keys(doc); - if(_.contains(keys,field)) { - field_array = field_array.concat(keys); - } - }); - var counts = _.countBy(_.without(field_array,field),function(field){return field;}); - return _.map(counts, function(num, key){return {name:key,count:num};}); - }; - - kbn.recurse_field_dots = function(object,field) { - var value = null; - var nested; - if (typeof object[field] !== 'undefined') { - value = object[field]; - } - else if (nested = field.match(/(.*?)\.(.*)/)) { - if(typeof object[nested[1]] !== 'undefined') { - value = (typeof object[nested[1]][nested[2]] !== 'undefined') ? - object[nested[1]][nested[2]] : kbn.recurse_field_dots( - object[nested[1]],nested[2]); - } - } - - return value; - }; - - kbn.top_field_values = function(docs,field,count,grouped) { - var all_values = _.pluck(docs,field), - groups = {}, - counts, - hasArrays; - // manually grouping into pairs allows us to keep the original value, - _.each(all_values, function (value) { - var k; - if(_.isArray(value)) { - hasArrays = true; - } - if(_.isArray(value) && !grouped) { - k = value; - } else { - k = _.isUndefined(value) ? '' : [value.toString()]; - } - _.each(k, function(key) { - if (_.has(groups, key)) { - groups[key][1] ++; - } else { - groups[key] = [(grouped ? value : key), 1]; - } - }); - }); - - counts = _.values(groups).sort(function(a, b) { - return a[1] - b[1]; - }).reverse().slice(0,count); - - return { - counts: counts, - hasArrays : hasArrays - }; - }; - /** * Calculate a graph interval *