mirror of
https://github.com/grafana/grafana.git
synced 2026-08-10 05:08:16 -05:00
provisioning: simplify db query
the GetProvisionedDashboardQuery wasent used for anything else than check if a dashboard is provisioned or not. So we simplified this query to make it more maintainable.
This commit is contained in:
@@ -102,13 +102,13 @@ func GetDashboard(c *m.ReqContext) Response {
|
||||
meta.FolderUrl = query.Result.GetUrl()
|
||||
}
|
||||
|
||||
dpQuery := &m.GetProvisionedDashboardByDashboardId{DashboardId: dash.Id}
|
||||
err = bus.Dispatch(dpQuery)
|
||||
isDashboardProvisioned := &m.IsDashboardProvisionedQuery{DashboardId: dash.Id}
|
||||
err = bus.Dispatch(isDashboardProvisioned)
|
||||
if err != nil {
|
||||
return Error(500, "Error while checking if dashboard is provisioned", err)
|
||||
}
|
||||
|
||||
if dpQuery.Result != nil {
|
||||
if isDashboardProvisioned.Result {
|
||||
meta.CanEdit = true
|
||||
meta.Provisioned = true
|
||||
}
|
||||
|
||||
@@ -42,8 +42,8 @@ func TestDashboardApiEndpoint(t *testing.T) {
|
||||
return nil
|
||||
})
|
||||
|
||||
bus.AddHandler("test", func(query *m.GetProvisionedDashboardByDashboardId) error {
|
||||
query.Result = nil
|
||||
bus.AddHandler("test", func(query *m.IsDashboardProvisionedQuery) error {
|
||||
query.Result = false
|
||||
return nil
|
||||
})
|
||||
|
||||
@@ -197,8 +197,8 @@ func TestDashboardApiEndpoint(t *testing.T) {
|
||||
fakeDash.HasAcl = true
|
||||
setting.ViewersCanEdit = false
|
||||
|
||||
bus.AddHandler("test", func(query *m.GetProvisionedDashboardByDashboardId) error {
|
||||
query.Result = nil
|
||||
bus.AddHandler("test", func(query *m.IsDashboardProvisionedQuery) error {
|
||||
query.Result = false
|
||||
return nil
|
||||
})
|
||||
|
||||
@@ -635,8 +635,8 @@ func TestDashboardApiEndpoint(t *testing.T) {
|
||||
dashTwo.FolderId = 3
|
||||
dashTwo.HasAcl = false
|
||||
|
||||
bus.AddHandler("test", func(query *m.GetProvisionedDashboardByDashboardId) error {
|
||||
query.Result = nil
|
||||
bus.AddHandler("test", func(query *m.IsDashboardProvisionedQuery) error {
|
||||
query.Result = false
|
||||
return nil
|
||||
})
|
||||
|
||||
@@ -766,8 +766,8 @@ func TestDashboardApiEndpoint(t *testing.T) {
|
||||
return nil
|
||||
})
|
||||
|
||||
bus.AddHandler("test", func(query *m.GetProvisionedDashboardByDashboardId) error {
|
||||
query.Result = nil
|
||||
bus.AddHandler("test", func(query *m.IsDashboardProvisionedQuery) error {
|
||||
query.Result = false
|
||||
return nil
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user