chore: move entity models into entity store service (#62145)

This commit is contained in:
Kristin Laemmert
2023-01-25 12:43:22 -05:00
committed by GitHub
parent 046a9bb7c1
commit dd147a3c31
27 changed files with 227 additions and 240 deletions
+7 -8
View File
@@ -10,7 +10,6 @@ import (
"github.com/grafana/grafana/pkg/infra/appcontext"
"github.com/grafana/grafana/pkg/infra/db"
"github.com/grafana/grafana/pkg/infra/log"
"github.com/grafana/grafana/pkg/models"
"github.com/grafana/grafana/pkg/services/dashboardsnapshots"
"github.com/grafana/grafana/pkg/services/playlist"
"github.com/grafana/grafana/pkg/services/sqlstore/session"
@@ -105,7 +104,7 @@ func (e *entityStoreJob) start(ctx context.Context) {
}
ctx = appcontext.WithUser(ctx, rowUser)
what := models.StandardKindFolder
what := entity.StandardKindFolder
e.status.Count[what] = 0
folders := make(map[int64]string)
@@ -133,7 +132,7 @@ func (e *entityStoreJob) start(ctx context.Context) {
_, err = e.store.AdminWrite(ctx, &entity.AdminWriteEntityRequest{
GRN: &entity.GRN{
UID: dash.UID,
Kind: models.StandardKindFolder,
Kind: entity.StandardKindFolder,
},
ClearHistory: true,
CreatedAt: dash.Created.UnixMilli(),
@@ -158,7 +157,7 @@ func (e *entityStoreJob) start(ctx context.Context) {
e.broadcaster(e.status)
}
what = models.StandardKindDashboard
what = entity.StandardKindDashboard
e.status.Count[what] = 0
// TODO paging etc
@@ -181,7 +180,7 @@ func (e *entityStoreJob) start(ctx context.Context) {
_, err = e.store.AdminWrite(ctx, &entity.AdminWriteEntityRequest{
GRN: &entity.GRN{
UID: dash.UID,
Kind: models.StandardKindDashboard,
Kind: entity.StandardKindDashboard,
},
ClearHistory: true,
Version: fmt.Sprintf("%d", dash.Version),
@@ -208,7 +207,7 @@ func (e *entityStoreJob) start(ctx context.Context) {
}
// Playlists
what = models.StandardKindPlaylist
what = entity.StandardKindPlaylist
e.status.Count[what] = 0
rowUser.OrgID = 1
rowUser.UserID = 1
@@ -233,7 +232,7 @@ func (e *entityStoreJob) start(ctx context.Context) {
_, err = e.store.Write(ctx, &entity.WriteEntityRequest{
GRN: &entity.GRN{
UID: playlist.Uid,
Kind: models.StandardKindPlaylist,
Kind: entity.StandardKindPlaylist,
},
Body: prettyJSON(playlist),
Comment: "export from playlists",
@@ -297,7 +296,7 @@ func (e *entityStoreJob) start(ctx context.Context) {
_, err = e.store.Write(ctx, &entity.WriteEntityRequest{
GRN: &entity.GRN{
UID: dto.Key,
Kind: models.StandardKindSnapshot,
Kind: entity.StandardKindSnapshot,
},
Body: prettyJSON(m),
Comment: "export from snapshtts",
+2 -2
View File
@@ -5,8 +5,8 @@ import (
"path/filepath"
"time"
"github.com/grafana/grafana/pkg/models"
"github.com/grafana/grafana/pkg/services/playlist"
"github.com/grafana/grafana/pkg/services/store/entity"
)
func exportSystemPlaylists(helper *commitHelper, job *gitExportJob) error {
@@ -41,7 +41,7 @@ func exportSystemPlaylists(helper *commitHelper, job *gitExportJob) error {
fpath: filepath.Join(
helper.orgDir,
"entity",
models.StandardKindPlaylist,
entity.StandardKindPlaylist,
fmt.Sprintf("%s.json", playlist.Uid)),
body: prettyJSON(playlist),
})