Fix to issue 2524 by limiting number of returned measurements for display. (#8092)

This commit is contained in:
sbhenderson 2017-04-24 04:44:29 -05:00 committed by Torkel Ödegaard
parent 92d723d6f5
commit c485fed744
2 changed files with 12 additions and 6 deletions

View File

@ -91,7 +91,13 @@ function (_) {
query += ' WHERE ' + whereConditions.join(' ');
}
}
if (type === 'MEASUREMENTS')
{
query += ' LIMIT 100';
//Solve issue #2524 by limiting the number of measurements returned
//LIMIT must be after WITH MEASUREMENT and WHERE clauses
//This also could be used for TAG KEYS and TAG VALUES, if desired
}
return query;
};

View File

@ -34,31 +34,31 @@ describe('InfluxQueryBuilder', function() {
it('should have no conditions in measurement query for query with no tags', function() {
var builder = new InfluxQueryBuilder({ measurement: '', tags: [] });
var query = builder.buildExploreQuery('MEASUREMENTS');
expect(query).to.be('SHOW MEASUREMENTS');
expect(query).to.be('SHOW MEASUREMENTS LIMIT 100');
});
it('should have no conditions in measurement query for query with no tags and empty query', function() {
var builder = new InfluxQueryBuilder({ measurement: '', tags: [] });
var query = builder.buildExploreQuery('MEASUREMENTS', undefined, '');
expect(query).to.be('SHOW MEASUREMENTS');
expect(query).to.be('SHOW MEASUREMENTS LIMIT 100');
});
it('should have WITH MEASUREMENT in measurement query for non-empty query with no tags', function() {
var builder = new InfluxQueryBuilder({ measurement: '', tags: [] });
var query = builder.buildExploreQuery('MEASUREMENTS', undefined, 'something');
expect(query).to.be('SHOW MEASUREMENTS WITH MEASUREMENT =~ /something/');
expect(query).to.be('SHOW MEASUREMENTS WITH MEASUREMENT =~ /something/ LIMIT 100');
});
it('should have WITH MEASUREMENT WHERE in measurement query for non-empty query with tags', function() {
var builder = new InfluxQueryBuilder({ measurement: '', tags: [{key: 'app', value: 'email'}] });
var query = builder.buildExploreQuery('MEASUREMENTS', undefined, 'something');
expect(query).to.be("SHOW MEASUREMENTS WITH MEASUREMENT =~ /something/ WHERE \"app\" = 'email'");
expect(query).to.be("SHOW MEASUREMENTS WITH MEASUREMENT =~ /something/ WHERE \"app\" = 'email' LIMIT 100");
});
it('should have where condition in measurement query for query with tags', function() {
var builder = new InfluxQueryBuilder({measurement: '', tags: [{key: 'app', value: 'email'}]});
var query = builder.buildExploreQuery('MEASUREMENTS');
expect(query).to.be("SHOW MEASUREMENTS WHERE \"app\" = 'email'");
expect(query).to.be("SHOW MEASUREMENTS WHERE \"app\" = 'email' LIMIT 100");
});
it('should have where tag name IN filter in tag values query for query with one tag', function() {