Commit 3b6bf80e by Torkel Ödegaard

removed more unused code

parent 0e4dc5a8
...@@ -4,94 +4,6 @@ function($, _, moment) { ...@@ -4,94 +4,6 @@ function($, _, moment) {
var kbn = {}; 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 * Calculate a graph interval
* *
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment