diff --git a/pkg/models/star.go b/pkg/models/star.go deleted file mode 100644 index 08e864d6c82..00000000000 --- a/pkg/models/star.go +++ /dev/null @@ -1,40 +0,0 @@ -package models - -import "errors" - -var ErrCommandValidationFailed = errors.New("command missing required fields") - -type Star struct { - Id int64 - UserId int64 - DashboardId int64 -} - -// ---------------------- -// COMMANDS - -type StarDashboardCommand struct { - UserId int64 - DashboardId int64 -} - -type UnstarDashboardCommand struct { - UserId int64 - DashboardId int64 -} - -// --------------------- -// QUERIES - -type GetUserStarsQuery struct { - UserId int64 - - Result map[int64]bool // dashboard ids -} - -type IsStarredByUserQuery struct { - UserId int64 - DashboardId int64 - - Result bool -} diff --git a/pkg/services/dashboards/database/database.go b/pkg/services/dashboards/database/database.go index faf257c7195..46ef267d094 100644 --- a/pkg/services/dashboards/database/database.go +++ b/pkg/services/dashboards/database/database.go @@ -22,6 +22,7 @@ import ( "github.com/grafana/grafana/pkg/services/sqlstore/migrator" "github.com/grafana/grafana/pkg/services/sqlstore/permissions" "github.com/grafana/grafana/pkg/services/sqlstore/searchstore" + "github.com/grafana/grafana/pkg/services/star" "github.com/grafana/grafana/pkg/services/store" "github.com/grafana/grafana/pkg/services/tag" "github.com/grafana/grafana/pkg/setting" @@ -963,7 +964,7 @@ func (d *DashboardStore) GetDashboardUIDById(ctx context.Context, query *models. func (d *DashboardStore) GetDashboards(ctx context.Context, query *models.GetDashboardsQuery) error { return d.store.WithDbSession(ctx, func(sess *db.Session) error { if len(query.DashboardIds) == 0 && len(query.DashboardUIds) == 0 { - return models.ErrCommandValidationFailed + return star.ErrCommandValidationFailed } var dashboards = make([]*models.Dashboard, 0) diff --git a/pkg/services/playlist/playlistimpl/sqlx_store.go b/pkg/services/playlist/playlistimpl/sqlx_store.go index 4def99ad6b9..a6321ae44a0 100644 --- a/pkg/services/playlist/playlistimpl/sqlx_store.go +++ b/pkg/services/playlist/playlistimpl/sqlx_store.go @@ -5,9 +5,9 @@ import ( "database/sql" "errors" - "github.com/grafana/grafana/pkg/models" "github.com/grafana/grafana/pkg/services/playlist" "github.com/grafana/grafana/pkg/services/sqlstore/session" + "github.com/grafana/grafana/pkg/services/star" ) type sqlxStore struct { @@ -171,7 +171,7 @@ func (s *sqlxStore) List(ctx context.Context, query *playlist.GetPlaylistsQuery) func (s *sqlxStore) GetItems(ctx context.Context, query *playlist.GetPlaylistItemsByUidQuery) ([]playlist.PlaylistItem, error) { var playlistItems = make([]playlist.PlaylistItem, 0) if query.PlaylistUID == "" || query.OrgId == 0 { - return playlistItems, models.ErrCommandValidationFailed + return playlistItems, star.ErrCommandValidationFailed } var p = playlist.Playlist{} diff --git a/pkg/services/playlist/playlistimpl/xorm_store.go b/pkg/services/playlist/playlistimpl/xorm_store.go index 99eb57e361e..218588dbeba 100644 --- a/pkg/services/playlist/playlistimpl/xorm_store.go +++ b/pkg/services/playlist/playlistimpl/xorm_store.go @@ -4,8 +4,8 @@ import ( "context" "github.com/grafana/grafana/pkg/infra/db" - "github.com/grafana/grafana/pkg/models" "github.com/grafana/grafana/pkg/services/playlist" + "github.com/grafana/grafana/pkg/services/star" "github.com/grafana/grafana/pkg/util" ) @@ -171,7 +171,7 @@ func (s *sqlStore) List(ctx context.Context, query *playlist.GetPlaylistsQuery) func (s *sqlStore) GetItems(ctx context.Context, query *playlist.GetPlaylistItemsByUidQuery) ([]playlist.PlaylistItem, error) { var playlistItems = make([]playlist.PlaylistItem, 0) if query.PlaylistUID == "" || query.OrgId == 0 { - return playlistItems, models.ErrCommandValidationFailed + return playlistItems, star.ErrCommandValidationFailed } err := s.db.WithDbSession(ctx, func(sess *db.Session) error { // getQuery the playlist Id