Return timezone applied or 0 if not present
This commit is contained in:
parent
c8286233be
commit
21b8655f85
@ -491,7 +491,8 @@ Histogram.prototype.format = function(result, override) {
|
||||
override = override || {};
|
||||
var buckets = [];
|
||||
|
||||
var aggregation = override && override.aggregation ? override.aggregation : this.aggregation;
|
||||
var aggregation = getAggregation(override, this.aggregation);
|
||||
var timezone = getTimezoneParam(override, this.timezone);
|
||||
var binsCount = getBinsCount(override);
|
||||
var width = getWidth(override);
|
||||
var binsStart = getBinStart(override);
|
||||
@ -513,6 +514,7 @@ Histogram.prototype.format = function(result, override) {
|
||||
|
||||
return {
|
||||
aggregation: aggregation,
|
||||
timezone: timezone,
|
||||
bin_width: width,
|
||||
bins_count: binsCount,
|
||||
bins_start: binsStart,
|
||||
@ -522,6 +524,20 @@ Histogram.prototype.format = function(result, override) {
|
||||
};
|
||||
};
|
||||
|
||||
function getAggregation(override, aggregation) {
|
||||
return override && override.aggregation ? override.aggregation : aggregation;
|
||||
}
|
||||
|
||||
function getTimezoneParam(override, timezone) {
|
||||
if (override && override.timezone) {
|
||||
return override.timezone;
|
||||
}
|
||||
if (timezone) {
|
||||
return timezone;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
function getBinStart(override) {
|
||||
if (override.hasOwnProperty('start') && override.hasOwnProperty('end')) {
|
||||
return Math.min(override.start, override.end);
|
||||
|
@ -561,6 +561,8 @@ describe('histogram-dataview for date column type', function() {
|
||||
self.testClient.getDataview('minute_histogram', params, function (err, dataviewWithTimezone) {
|
||||
assert.ifError(err);
|
||||
|
||||
assert.notEqual(dataview.timezone, dataviewWithTimezone.timezone);
|
||||
dataview.timezone = dataviewWithTimezone.timezone;
|
||||
assert.deepEqual(dataview, dataviewWithTimezone);
|
||||
done();
|
||||
});
|
||||
@ -593,7 +595,9 @@ describe('histogram-dataview for date column type', function() {
|
||||
function (err, filteredWithTimezoneDataview) {
|
||||
assert.ifError(err);
|
||||
|
||||
assert.deepEqual(filteredDataview, filteredWithTimezoneDataview);
|
||||
assert.notEqual(filteredWithTimezoneDataview.timezone, filteredDataview.timezone);
|
||||
filteredWithTimezoneDataview.timezone = filteredDataview.timezone;
|
||||
assert.deepEqual(filteredWithTimezoneDataview, filteredDataview);
|
||||
done();
|
||||
});
|
||||
});
|
||||
@ -614,6 +618,7 @@ describe('histogram-dataview for date column type', function() {
|
||||
bin_width: 600,
|
||||
bins_count: 2,
|
||||
bins_start: 1171497600,
|
||||
timezone: 0,
|
||||
nulls: 0,
|
||||
bins:
|
||||
[{
|
||||
@ -660,6 +665,7 @@ describe('histogram-dataview for date column type', function() {
|
||||
bins_count: 1,
|
||||
bins_start: 1171501200,
|
||||
nulls: 0,
|
||||
timezone: -3600,
|
||||
bins:
|
||||
[{
|
||||
bin: 0,
|
||||
|
Loading…
Reference in New Issue
Block a user