read aggregate functions from database
This commit is contained in:
@@ -24,9 +24,10 @@ export default class PostgresQuery {
|
||||
target.where = target.where || [];
|
||||
target.select = target.select || [[{ type: 'column', params: ['value'] }]];
|
||||
|
||||
this.updateProjection();
|
||||
// give interpolateQueryStr access to this
|
||||
this.interpolateQueryStr = this.interpolateQueryStr.bind(this);
|
||||
|
||||
this.updateProjection();
|
||||
}
|
||||
|
||||
quoteIdentifier(value) {
|
||||
|
||||
@@ -77,9 +77,19 @@ export class PostgresQueryCtrl extends QueryCtrl {
|
||||
});
|
||||
this.panelCtrl.events.on('data-received', this.onDataReceived.bind(this), $scope);
|
||||
this.panelCtrl.events.on('data-error', this.onDataError.bind(this), $scope);
|
||||
|
||||
}
|
||||
|
||||
buildSelectMenu() {
|
||||
|
||||
if (!queryPart.hasAggregates()) {
|
||||
this.datasource.metricFindQuery(this.queryBuilder.buildAggregateQuery())
|
||||
.then(results => {
|
||||
queryPart.clearAggregates();
|
||||
_.map(results, segment => { queryPart.registerAggregate(segment.text); });
|
||||
})
|
||||
.catch(this.handleQueryError.bind(this));
|
||||
}
|
||||
var categories = queryPart.getCategories();
|
||||
this.selectMenu = _.reduce(
|
||||
categories,
|
||||
@@ -279,6 +289,7 @@ export class PostgresQueryCtrl extends QueryCtrl {
|
||||
var datatype = results[0].text;
|
||||
switch (datatype) {
|
||||
case "text":
|
||||
case "character":
|
||||
case "character varying":
|
||||
return this.$q.when(this.uiSegmentSrv.newOperators(['=', '!=', '~', '~*','!~','!~*','IN']));
|
||||
default:
|
||||
|
||||
@@ -23,6 +23,17 @@ function register(options: any) {
|
||||
options.category.push(index[options.type]);
|
||||
}
|
||||
|
||||
function registerAggregate(name: string) {
|
||||
register({
|
||||
type: name,
|
||||
addStrategy: replaceAggregationAddStrategy,
|
||||
category: categories.Aggregations,
|
||||
params: [],
|
||||
defaultParams: [],
|
||||
renderer: functionRenderer,
|
||||
});
|
||||
}
|
||||
|
||||
var groupByTimeFunctions = [];
|
||||
|
||||
function aliasRenderer(part, innerExpr) {
|
||||
@@ -192,6 +203,12 @@ register({
|
||||
|
||||
export default {
|
||||
create: createPart,
|
||||
registerAggregate: registerAggregate,
|
||||
clearAggregates: function() { categories.Aggregations = []; },
|
||||
hasAggregates: function() {
|
||||
// FIXME
|
||||
return categories.Aggregations.length > 6;
|
||||
},
|
||||
getCategories: function() {
|
||||
return categories;
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user