Merge pull request #5290 from epixa/5286-correct-index-timerange

Use correct time range for index constraints
This commit is contained in:
Spencer 2015-11-03 15:21:44 -06:00
commit 866678fdf0
2 changed files with 10 additions and 10 deletions

View file

@ -50,21 +50,21 @@ describe('ui/index_patterns/_calculate_indices', () => {
context('when given start', () => {
beforeEach(() => run({ start: '1234567890' }));
it('includes min_value', () => {
expect(constraints['@something']).to.have.property('min_value');
it('includes max_value', () => {
expect(constraints['@something']).to.have.property('max_value');
});
it('min_value is gte', () => {
expect(constraints['@something'].min_value).to.have.property('gte');
it('max_value is gte', () => {
expect(constraints['@something'].max_value).to.have.property('gte');
});
});
context('when given stop', () => {
beforeEach(() => run({ stop: '1234567890' }));
it('includes max_value', () => {
expect(constraints['@something']).to.have.property('max_value');
it('includes min_value', () => {
expect(constraints['@something']).to.have.property('min_value');
});
it('max_value is lt', () => {
expect(constraints['@something'].max_value).to.have.property('lt');
it('min_value is lte', () => {
expect(constraints['@something'].min_value).to.have.property('lte');
});
});
});

View file

@ -17,10 +17,10 @@ define(function (require) {
function compileOptions(pattern, timeFieldName, start, stop) {
const constraints = {};
if (start) {
constraints.min_value = { gte: moment(start).valueOf() };
constraints.max_value = { gte: moment(start).valueOf() };
}
if (stop) {
constraints.max_value = { lt: moment(stop).valueOf() };
constraints.min_value = { lte: moment(stop).valueOf() };
}
return {