Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
VladLasitsa committed Apr 1, 2020
1 parent bb688e6 commit 3a93cc2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
6 changes: 4 additions & 2 deletions src/plugins/data/public/search/aggs/buckets/date_histogram.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,11 @@ const updateTimeBuckets = (
timefilter: TimefilterContract,
customBuckets?: IBucketDateHistogramAggConfig['buckets']
) => {
const bounds = agg.params.timeRange ? timefilter.calculateBounds(agg.params.timeRange) : null;
const bounds = agg.params.timeRange
? timefilter.calculateBounds(agg.params.timeRange)
: undefined;
const buckets = customBuckets || agg.buckets;
buckets.setBounds(agg.fieldIsTimeField() ? bounds : null);
buckets.setBounds(agg.fieldIsTimeField() ? bounds : undefined);
buckets.setInterval(agg.params.interval);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

import _ from 'lodash';
import moment from 'moment';
import moment, { Moment } from 'moment';

import { IUiSettingsClient } from 'src/core/public';
import { parseInterval } from '../../../../../../common';
Expand Down Expand Up @@ -194,7 +194,7 @@ export class TimeBuckets {
*
* @returns {undefined}
*/
setBounds(input?: null | TimeRangeBounds | TimeRangeBounds[]) {
setBounds(input?: TimeRangeBounds | TimeRangeBounds[]) {
if (!input) return this.clearBounds();

let bounds;
Expand All @@ -205,11 +205,9 @@ export class TimeBuckets {
bounds = Array.isArray(input) ? input : [];
}

const moments = _(bounds)
.map(_.ary(moment, 1))
.sortBy(Number);
const moments: Moment[] = _.sortBy(bounds, Number);

const valid = moments.size() === 2 && moments.every(isValidMoment);
const valid = moments.length === 2 && moments.every(isValidMoment);
if (!valid) {
this.clearBounds();
throw new Error('invalid bounds set: ' + input);
Expand Down
6 changes: 4 additions & 2 deletions src/plugins/visualizations/public/legacy/build_pipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,10 @@ const getSchemas = (
const createSchemaConfig = (accessor: number, agg: IAggConfig): SchemaConfig => {
if (isDateHistogramBucketAggConfig(agg)) {
agg.params.timeRange = timeRange;
const bounds = agg.params.timeRange ? timefilter.calculateBounds(agg.params.timeRange) : null;
agg.buckets.setBounds(agg.fieldIsTimeField() ? bounds : null);
const bounds = agg.params.timeRange
? timefilter.calculateBounds(agg.params.timeRange)
: undefined;
agg.buckets.setBounds(agg.fieldIsTimeField() ? bounds : undefined);
agg.buckets.setInterval(agg.params.interval);
}

Expand Down

0 comments on commit 3a93cc2

Please sign in to comment.