diff --git a/pkg/api/playlist_play.go b/pkg/api/playlist_play.go index 735ac41e33f..9bfcf1532fa 100644 --- a/pkg/api/playlist_play.go +++ b/pkg/api/playlist_play.go @@ -14,7 +14,7 @@ func populateDashboardsById(dashboardByIds []int64) ([]m.PlaylistDashboardDto, e result := make([]m.PlaylistDashboardDto, 0) if len(dashboardByIds) > 0 { - dashboardQuery := m.GetPlaylistDashboardsQuery{DashboardIds: dashboardByIds} + dashboardQuery := m.GetDashboardsQuery{DashboardIds: dashboardByIds} if err := bus.Dispatch(&dashboardQuery); err != nil { return result, errors.New("Playlist not found") //TODO: dont swallow error } diff --git a/pkg/models/dashboards.go b/pkg/models/dashboards.go index ddf5dd244f5..63ed1f5c006 100644 --- a/pkg/models/dashboards.go +++ b/pkg/models/dashboards.go @@ -146,3 +146,8 @@ type GetDashboardTagsQuery struct { OrgId int64 Result []*DashboardTagCloudItem } + +type GetDashboardsQuery struct { + DashboardIds []int64 + Result *[]Dashboard +} diff --git a/pkg/models/playlist.go b/pkg/models/playlist.go index 1eb2e1ea915..6ebcb0ff577 100644 --- a/pkg/models/playlist.go +++ b/pkg/models/playlist.go @@ -119,8 +119,3 @@ type GetPlaylistItemsByIdQuery struct { PlaylistId int64 Result *[]PlaylistItem } - -type GetPlaylistDashboardsQuery struct { - DashboardIds []int64 - Result *PlaylistDashboards -} diff --git a/pkg/services/sqlstore/dashboard.go b/pkg/services/sqlstore/dashboard.go index bbec541589c..2a8ff2dc941 100644 --- a/pkg/services/sqlstore/dashboard.go +++ b/pkg/services/sqlstore/dashboard.go @@ -14,6 +14,7 @@ import ( func init() { bus.AddHandler("sql", SaveDashboard) bus.AddHandler("sql", GetDashboard) + bus.AddHandler("sql", GetDashboards) bus.AddHandler("sql", DeleteDashboard) bus.AddHandler("sql", SearchDashboards) bus.AddHandler("sql", GetDashboardTags) @@ -223,3 +224,20 @@ func DeleteDashboard(cmd *m.DeleteDashboardCommand) error { return nil }) } + +func GetDashboards(query *m.GetDashboardsQuery) error { + if len(query.DashboardIds) == 0 { + return m.ErrCommandValidationFailed + } + + var dashboards = make([]m.Dashboard, 0) + + err := x.In("id", query.DashboardIds).Find(&dashboards) + query.Result = &dashboards + + if err != nil { + return err + } + + return nil +} diff --git a/pkg/services/sqlstore/playlist.go b/pkg/services/sqlstore/playlist.go index ee0b3b950c7..56fae9d3feb 100644 --- a/pkg/services/sqlstore/playlist.go +++ b/pkg/services/sqlstore/playlist.go @@ -15,7 +15,6 @@ func init() { bus.AddHandler("sql", DeletePlaylist) bus.AddHandler("sql", SearchPlaylists) bus.AddHandler("sql", GetPlaylist) - bus.AddHandler("sql", GetPlaylistDashboards) bus.AddHandler("sql", GetPlaylistItem) } @@ -162,20 +161,3 @@ func GetPlaylistItem(query *m.GetPlaylistItemsByIdQuery) error { return err } - -func GetPlaylistDashboards(query *m.GetPlaylistDashboardsQuery) error { - if len(query.DashboardIds) == 0 { - return m.ErrCommandValidationFailed - } - - var dashboards = make(m.PlaylistDashboards, 0) - - err := x.In("id", query.DashboardIds).Find(&dashboards) - query.Result = &dashboards - - if err != nil { - return err - } - - return nil -}