mirror of https://github.com/grafana/grafana.git
				
				
				
			Chore: Remove star model duplicates (#61191)
This commit is contained in:
		
							parent
							
								
									320266ae63
								
							
						
					
					
						commit
						9a14a7db03
					
				|  | @ -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 | ||||
| } | ||||
|  | @ -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) | ||||
|  |  | |||
|  | @ -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{} | ||||
|  |  | |||
|  | @ -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
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue