Elasticsearch: revert to isoWeek when resolving weekly indices (#31709)

* Elasticsearch: revert to isoWeek when resolving weekly indices

* Add type assertion explainer
This commit is contained in:
Giordano Ricci
2021-03-05 09:28:46 +00:00
committed by GitHub
parent fb58c06383
commit bbee7da3e0
3 changed files with 19 additions and 3 deletions

View File

@@ -12,7 +12,7 @@ type IntervalMap = Record<
const intervalMap: IntervalMap = {
Hourly: { startOf: 'hour', amount: 'hours' },
Daily: { startOf: 'day', amount: 'days' },
Weekly: { startOf: 'week', amount: 'weeks' },
Weekly: { startOf: 'isoWeek', amount: 'weeks' },
Monthly: { startOf: 'month', amount: 'months' },
Yearly: { startOf: 'year', amount: 'years' },
};

View File

@@ -55,6 +55,20 @@ describe('IndexPattern', () => {
expect(pattern.getIndexList(from, to)).toEqual(expected);
});
});
describe('weekly', () => {
it('should return correct index list', () => {
const pattern = new IndexPattern('[asd-]YYYY.WW', 'Weekly');
// Sunday, February 21, 2021 1:00:00 AM
const from = dateTime(new Date(1613869200000));
// Friday, March 5, 2021 1:00:00 AM
const to = dateTime(new Date(1614906000000));
const expected = ['asd-2021.07', 'asd-2021.08', 'asd-2021.09'];
expect(pattern.getIndexList(from, to)).toEqual(expected);
});
});
});
describe('when getting index list from single date', () => {