Public Dashboards: Add Expressions Support (#54336)

Adds support for expressions with public dashboards
This commit is contained in:
owensmallwood
2022-08-31 09:11:10 -06:00
committed by GitHub
parent 76ea0b15ae
commit f4bbce15a0
7 changed files with 197 additions and 11 deletions
+5 -2
View File
@@ -16,6 +16,7 @@ import (
"github.com/grafana/grafana/pkg/plugins/adapters"
"github.com/grafana/grafana/pkg/services/datasources"
"github.com/grafana/grafana/pkg/services/oauthtoken"
queryModels "github.com/grafana/grafana/pkg/services/query/models"
"github.com/grafana/grafana/pkg/services/user"
"github.com/grafana/grafana/pkg/setting"
"github.com/grafana/grafana/pkg/tsdb/grafanads"
@@ -80,13 +81,15 @@ func (s *Service) QueryData(ctx context.Context, user *user.SignedInUser, skipCa
// QueryData can process queries and return query responses.
func (s *Service) QueryDataMultipleSources(ctx context.Context, user *user.SignedInUser, skipCache bool, reqDTO dtos.MetricRequest, handleExpressions bool) (*backend.QueryDataResponse, error) {
byDataSource := models.GroupQueriesByDataSource(reqDTO.Queries)
byDataSource := queryModels.GroupQueriesByDataSource(reqDTO.Queries)
if len(byDataSource) == 1 {
// The expression service will handle mixed datasources, so we don't need to group them when an expression is present.
if queryModels.HasExpressionQuery(reqDTO.Queries) || len(byDataSource) == 1 {
return s.QueryData(ctx, user, skipCache, reqDTO, handleExpressions)
} else {
resp := backend.NewQueryDataResponse()
// create new reqDTO with only the queries for that datasource
for _, queries := range byDataSource {
subDTO := reqDTO.CloneWithQueries(queries)