Skip to content

Commit

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

Expand Down
9 changes: 5 additions & 4 deletions src/plugins/visualizations/public/legacy/build_pipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,11 @@ 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)
: undefined;
agg.buckets.setBounds(agg.fieldIsTimeField() ? bounds : undefined);
const bounds =
agg.params.timeRange && agg.fieldIsTimeField()
? timefilter.calculateBounds(agg.params.timeRange)
: undefined;
agg.buckets.setBounds(bounds);
agg.buckets.setInterval(agg.params.interval);
}

Expand Down

0 comments on commit a4ea0d6

Please sign in to comment.