mirror of
https://github.com/grafana/grafana.git
synced 2026-07-30 08:18:10 -05:00
Public Dashboards: Query Caching (#51403)
* passes id and uid to PublicDashboardDatasource * betterer results * If for a public dashboard, return the PublicDashboardDataSource first or else getDatasourceSrv.get() will fail bc of no authed user. Added some unit tests for resolving the uid from the many possible datasource types. * updates betterer * Exports DashboardService. Adds method to DashboardService to build anonymous user for use with public dashboards where there is no authed user. Adds method on dashboard_queries to get all dashboard uids from a dashboard. * refactors to get unique datasource uids * Adds tests for getting all unique datasource uids off a dashboard * adds test for building anonymous user with read and query actions that are scoped to each datasource uid in the dashboard * updates casing of DashboardService * updates test case to have additional panel with a different datasource * gives default interval to public dashboard data source
This commit is contained in:
@@ -53,7 +53,7 @@ func (hs *HTTPServer) GetAnnotations(c *models.ReqContext) response.Response {
|
||||
item.DashboardUID = val
|
||||
} else {
|
||||
query := models.GetDashboardQuery{Id: item.DashboardId, OrgId: c.OrgId}
|
||||
err := hs.dashboardService.GetDashboard(c.Req.Context(), &query)
|
||||
err := hs.DashboardService.GetDashboard(c.Req.Context(), &query)
|
||||
if err == nil && query.Result != nil {
|
||||
item.DashboardUID = &query.Result.Uid
|
||||
dashboardCache[item.DashboardId] = &query.Result.Uid
|
||||
@@ -82,7 +82,7 @@ func (hs *HTTPServer) PostAnnotation(c *models.ReqContext) response.Response {
|
||||
// overwrite dashboardId when dashboardUID is not empty
|
||||
if cmd.DashboardUID != "" {
|
||||
query := models.GetDashboardQuery{OrgId: c.OrgId, Uid: cmd.DashboardUID}
|
||||
err := hs.dashboardService.GetDashboard(c.Req.Context(), &query)
|
||||
err := hs.DashboardService.GetDashboard(c.Req.Context(), &query)
|
||||
if err == nil {
|
||||
cmd.DashboardId = query.Result.Id
|
||||
}
|
||||
@@ -291,7 +291,7 @@ func (hs *HTTPServer) MassDeleteAnnotations(c *models.ReqContext) response.Respo
|
||||
|
||||
if cmd.DashboardUID != "" {
|
||||
query := models.GetDashboardQuery{OrgId: c.OrgId, Uid: cmd.DashboardUID}
|
||||
err := hs.dashboardService.GetDashboard(c.Req.Context(), &query)
|
||||
err := hs.DashboardService.GetDashboard(c.Req.Context(), &query)
|
||||
if err == nil {
|
||||
cmd.DashboardId = query.Result.Id
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user