Skip to content

Commit

Permalink
removing timezone from date histogram
Browse files Browse the repository at this point in the history
  • Loading branch information
simianhacker committed Oct 3, 2018
1 parent 46091ff commit 16450f5
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ describe('dateHistogram(req, panel, series)', () => {
field: '@timestamp',
interval: '10s',
min_doc_count: 0,
time_zone: 'UTC',
offset: '-10s',
extended_bounds: {
min: 1483228800000,
Expand Down Expand Up @@ -111,7 +110,6 @@ describe('dateHistogram(req, panel, series)', () => {
field: '@timestamp',
interval: '10s',
min_doc_count: 0,
time_zone: 'UTC',
offset: '-10s',
extended_bounds: {
min: 1483225200000,
Expand Down Expand Up @@ -156,7 +154,6 @@ describe('dateHistogram(req, panel, series)', () => {
field: 'timestamp',
interval: '20s',
min_doc_count: 0,
time_zone: 'UTC',
offset: '-20s',
extended_bounds: {
min: 1483228800000,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ export default function dateHistogram(req, panel, series) {
const { timeField, interval } = getIntervalAndTimefield(panel, series);
const { bucketSize, intervalString } = getBucketSize(req, interval);
const { from, to } = offsetTime(req, series.offset_time, panel);
const { timezone } = req.payload.timerange;

const offset = getBucketOffset(from.valueOf(), bucketSize * 1000);
const offsetString = `${Math.floor(offset / 1000)}s`;
Expand All @@ -45,7 +44,6 @@ export default function dateHistogram(req, panel, series) {
field: timeField,
interval: intervalString,
min_doc_count: 0,
time_zone: timezone,
offset: offsetString,
extended_bounds: {
min: boundsMin.valueOf(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,16 @@ import getTimerange from '../../helpers/get_timerange';
import { calculateAggRoot } from './calculate_agg_root';
import { isMetric } from '../../../../../common/metric_types';
import { hasSiblingAggs } from '../../helpers/has_sibling_aggs';
import { getBucketOffset } from '../../helpers/get_bucket_offset';

export default function dateHistogram(req, panel) {
return next => doc => {
const { timeField, interval } = getIntervalAndTimefield(panel);
const { bucketSize, intervalString } = getBucketSize(req, interval);
const { from, to } = getTimerange(req);
const offset = getBucketOffset(from.valueOf(), bucketSize * 1000);
const offsetString = `${Math.floor(offset / 1000)}s`;

panel.series.forEach(column => {
const aggRoot = calculateAggRoot(doc, column);
if (isMetric(panel.type) && panel.timerange_mode === 'all') {
Expand All @@ -42,6 +46,7 @@ export default function dateHistogram(req, panel) {
field: timeField,
interval: intervalString,
min_doc_count: 0,
offset: offsetString,
extended_bounds: {
min: boundsMin.valueOf(),
max: to.valueOf()
Expand All @@ -53,7 +58,8 @@ export default function dateHistogram(req, panel) {
from: from.toISOString(),
timeField,
intervalString,
bucketSize
bucketSize,
offset: offsetString
});
});
return next(doc);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ describe('buildRequestBody(req)', () => {
field: '@timestamp',
interval: '10s',
min_doc_count: 0,
time_zone: 'UTC',
offset: '-5s',
extended_bounds: {
min: 1485463055881,
Expand Down

0 comments on commit 16450f5

Please sign in to comment.