Skip to content

Commit

Permalink
Fix date histogram fails on rollup index (elastic#97369) (elastic#97613)
Browse files Browse the repository at this point in the history
Closes: elastic#97125

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
  • Loading branch information
alexwizp and kibanamachine authored Apr 20, 2021
1 parent eab6129 commit 065f348
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ describe('TimeBuckets', () => {
}
});

test('setInterval/getInterval - intreval is a "auto"', () => {
test('setInterval/getInterval - interval is a "auto"', () => {
const timeBuckets = new TimeBuckets(timeBucketConfig);
timeBuckets.setInterval(autoInterval);
const interval = timeBuckets.getInterval();
Expand All @@ -120,6 +120,16 @@ describe('TimeBuckets', () => {
expect(interval.expression).toEqual('0ms');
});

test('setInterval/getInterval - interval is a "auto" (useNormalizedEsInterval is false)', () => {
const timeBuckets = new TimeBuckets(timeBucketConfig);
timeBuckets.setInterval(autoInterval);
const interval = timeBuckets.getInterval(false);

expect(interval.esValue).toEqual(0);
expect(interval.esUnit).toEqual('ms');
expect(interval.expression).toEqual('0ms');
});

test('getScaledDateFormat', () => {
const timeBuckets = new TimeBuckets(timeBucketConfig);
timeBuckets.setInterval('20m');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,9 +267,10 @@ export class TimeBuckets {
originalUnit = splitStringInterval(this._originalInterval!)?.unit;
}

const esInterval = useNormalizedEsInterval
? convertDurationToNormalizedEsInterval(interval, originalUnit)
: convertIntervalToEsInterval(String(this._originalInterval));
const esInterval =
useNormalizedEsInterval || !this._originalInterval
? convertDurationToNormalizedEsInterval(interval, originalUnit)
: convertIntervalToEsInterval(this._originalInterval);

const prettyUnits = moment.normalizeUnits(esInterval.unit);

Expand Down

0 comments on commit 065f348

Please sign in to comment.