mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
fix metric column when using group by
This commit is contained in:
parent
3af4e4e0d6
commit
a5bcd8eac0
@ -28,6 +28,20 @@
|
||||
|
||||
</div>
|
||||
|
||||
<div class="gf-form-inline">
|
||||
<div class="gf-form">
|
||||
<label class="gf-form-label query-keyword width-7">Time column</label>
|
||||
<metric-segment segment="ctrl.timeColumnSegment" get-options="ctrl.getTimeColumnSegments()" on-change="ctrl.timeColumnChanged()"></metric-segment>
|
||||
<label class="gf-form-label query-keyword width-8">Metric column</label>
|
||||
<metric-segment segment="ctrl.metricColumnSegment" get-options="ctrl.getMetricColumnSegments()" on-change="ctrl.metricColumnChanged()"></metric-segment>
|
||||
</div>
|
||||
|
||||
<div class="gf-form gf-form--grow">
|
||||
<div class="gf-form-label gf-form-label--grow"></div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="gf-form-inline" ng-repeat="selectParts in ctrl.queryModel.selectModels">
|
||||
<div class="gf-form">
|
||||
<label class="gf-form-label query-keyword width-7">
|
||||
@ -52,20 +66,6 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="gf-form-inline">
|
||||
<div class="gf-form">
|
||||
<label class="gf-form-label query-keyword width-7">Time column</label>
|
||||
<metric-segment segment="ctrl.timeColumnSegment" get-options="ctrl.getTimeColumnSegments()" on-change="ctrl.timeColumnChanged()"></metric-segment>
|
||||
<label class="gf-form-label query-keyword width-8">Metric column</label>
|
||||
<metric-segment segment="ctrl.metricColumnSegment" get-options="ctrl.getMetricColumnSegments()" on-change="ctrl.metricColumnChanged()"></metric-segment>
|
||||
</div>
|
||||
|
||||
<div class="gf-form gf-form--grow">
|
||||
<div class="gf-form-label gf-form-label--grow"></div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="gf-form-inline">
|
||||
<div class="gf-form">
|
||||
<label class="gf-form-label query-keyword width-7">
|
||||
|
@ -175,9 +175,13 @@ export default class PostgresQuery {
|
||||
} else {
|
||||
args = timeGroup.params[0];
|
||||
}
|
||||
query += '$__timeGroup(' + this.quoteIdentifier(target.timeColumn) + ',' + args + '),';
|
||||
query += '$__timeGroup(' + this.quoteIdentifier(target.timeColumn) + ',' + args + ')';
|
||||
} else {
|
||||
query += this.quoteIdentifier(target.timeColumn) + ' AS time,';
|
||||
query += this.quoteIdentifier(target.timeColumn) + ' AS time';
|
||||
}
|
||||
|
||||
if (this.target.metricColumn !== 'None') {
|
||||
query += "," + this.quoteIdentifier(this.target.metricColumn) + " AS metric";
|
||||
}
|
||||
|
||||
var i, y;
|
||||
@ -189,14 +193,7 @@ export default class PostgresQuery {
|
||||
selectText = part.render(selectText);
|
||||
}
|
||||
|
||||
if (i > 0) {
|
||||
query += ', ';
|
||||
}
|
||||
query += selectText;
|
||||
}
|
||||
|
||||
if (this.target.metricColumn !== 'None') {
|
||||
query += "," + this.quoteIdentifier(this.target.metricColumn) + " AS metric";
|
||||
query += ', ' + selectText;
|
||||
}
|
||||
|
||||
query += ' FROM ' + this.quoteIdentifier(target.schema) + '.' + this.quoteIdentifier(target.table) + ' WHERE ';
|
||||
@ -225,6 +222,9 @@ export default class PostgresQuery {
|
||||
|
||||
if (groupBySection.length) {
|
||||
query += ' GROUP BY ' + groupBySection;
|
||||
if (this.target.metricColumn !== "None") {
|
||||
query += ",2";
|
||||
}
|
||||
}
|
||||
|
||||
query += ' ORDER BY 1';
|
||||
|
Loading…
Reference in New Issue
Block a user