Commit 407f1ad4 by Torkel Ödegaard

Merge branch 'master' of https://github.com/pdoan017/grafana

parents 62f57709 3eea5d23
package mysql package mysql
import ( import (
"container/list"
"context" "context"
"database/sql" "database/sql"
"fmt" "fmt"
...@@ -245,6 +246,7 @@ func (e MysqlExecutor) getTypedRowData(types []*sql.ColumnType, rows *core.Rows) ...@@ -245,6 +246,7 @@ func (e MysqlExecutor) getTypedRowData(types []*sql.ColumnType, rows *core.Rows)
func (e MysqlExecutor) TransformToTimeSeries(query *tsdb.Query, rows *core.Rows, result *tsdb.QueryResult) error { func (e MysqlExecutor) TransformToTimeSeries(query *tsdb.Query, rows *core.Rows, result *tsdb.QueryResult) error {
pointsBySeries := make(map[string]*tsdb.TimeSeries) pointsBySeries := make(map[string]*tsdb.TimeSeries)
seriesByQueryOrder := list.New()
columnNames, err := rows.Columns() columnNames, err := rows.Columns()
if err != nil { if err != nil {
...@@ -282,11 +284,13 @@ func (e MysqlExecutor) TransformToTimeSeries(query *tsdb.Query, rows *core.Rows, ...@@ -282,11 +284,13 @@ func (e MysqlExecutor) TransformToTimeSeries(query *tsdb.Query, rows *core.Rows,
series := &tsdb.TimeSeries{Name: rowData.metric} series := &tsdb.TimeSeries{Name: rowData.metric}
series.Points = append(series.Points, tsdb.TimePoint{rowData.value, rowData.time}) series.Points = append(series.Points, tsdb.TimePoint{rowData.value, rowData.time})
pointsBySeries[rowData.metric] = series pointsBySeries[rowData.metric] = series
seriesByQueryOrder.PushBack(rowData.metric)
} }
} }
for _, value := range pointsBySeries { for elem := seriesByQueryOrder.Front(); elem != nil; elem = elem.Next() {
result.Series = append(result.Series, value) key := elem.Value.(string)
result.Series = append(result.Series, pointsBySeries[key])
} }
result.Meta.Set("rowCount", rowCount) result.Meta.Set("rowCount", rowCount)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment