chore: move entity models into entity store service (#62145)
This commit is contained in:
@@ -4,7 +4,6 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
|
||||
"github.com/grafana/grafana/pkg/models"
|
||||
"github.com/grafana/grafana/pkg/services/sqlstore/session"
|
||||
"github.com/grafana/grafana/pkg/services/store/entity"
|
||||
)
|
||||
@@ -41,7 +40,7 @@ func updateFolderTree(ctx context.Context, tx *session.SessionTx, tenant int64)
|
||||
|
||||
all := []*folderInfo{}
|
||||
rows, err := tx.Query(ctx, "SELECT uid,folder,name,slug FROM entity WHERE kind=? AND tenant_id=? ORDER BY slug asc;",
|
||||
models.StandardKindFolder, tenant)
|
||||
entity.StandardKindFolder, tenant)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -135,7 +134,7 @@ func setMPTTOrder(folder *folderInfo, stack []*folderInfo, idx int32) (int32, er
|
||||
|
||||
func insertFolderInfo(ctx context.Context, tx *session.SessionTx, tenant int64, folder *folderInfo, isDetached bool) error {
|
||||
js, _ := json.Marshal(folder.stack)
|
||||
grn := entity.GRN{TenantId: tenant, Kind: models.StandardKindFolder, UID: folder.UID}
|
||||
grn := entity.GRN{TenantId: tenant, Kind: entity.StandardKindFolder, UID: folder.UID}
|
||||
_, err := tx.Exec(ctx,
|
||||
`INSERT INTO entity_folder `+
|
||||
"(grn, tenant_id, uid, slug_path, tree, depth, left, right, detached) "+
|
||||
|
||||
@@ -13,7 +13,6 @@ import (
|
||||
"github.com/grafana/grafana/pkg/infra/db"
|
||||
"github.com/grafana/grafana/pkg/infra/log"
|
||||
"github.com/grafana/grafana/pkg/infra/slugify"
|
||||
"github.com/grafana/grafana/pkg/models"
|
||||
"github.com/grafana/grafana/pkg/services/grpcserver"
|
||||
"github.com/grafana/grafana/pkg/services/sqlstore/session"
|
||||
"github.com/grafana/grafana/pkg/services/store"
|
||||
@@ -447,7 +446,7 @@ func (s *sqlEntityServer) AdminWrite(ctx context.Context, r *entity.AdminWriteEn
|
||||
origin.Source, origin.Key, origin.Time,
|
||||
)
|
||||
}
|
||||
if err == nil && models.StandardKindFolder == r.GRN.Kind {
|
||||
if err == nil && entity.StandardKindFolder == r.GRN.Kind {
|
||||
err = updateFolderTree(ctx, tx, grn.TenantId)
|
||||
}
|
||||
if err == nil {
|
||||
@@ -663,7 +662,7 @@ func doDelete(ctx context.Context, tx *session.SessionTx, grn *entity.GRN) (bool
|
||||
return false, err
|
||||
}
|
||||
|
||||
if grn.Kind == models.StandardKindFolder {
|
||||
if grn.Kind == entity.StandardKindFolder {
|
||||
err = updateFolderTree(ctx, tx, grn.TenantId)
|
||||
}
|
||||
return rows > 0, err
|
||||
|
||||
@@ -3,12 +3,11 @@ package sqlstash
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/grafana/grafana/pkg/models"
|
||||
"github.com/grafana/grafana/pkg/services/store/entity"
|
||||
)
|
||||
|
||||
type summarySupport struct {
|
||||
model *models.EntitySummary
|
||||
model *entity.EntitySummary
|
||||
name string
|
||||
description *string // null or empty
|
||||
slug *string // null or empty
|
||||
@@ -23,7 +22,7 @@ type summarySupport struct {
|
||||
isNested bool // set when this is for a nested item
|
||||
}
|
||||
|
||||
func newSummarySupport(summary *models.EntitySummary) (*summarySupport, error) {
|
||||
func newSummarySupport(summary *entity.EntitySummary) (*summarySupport, error) {
|
||||
var err error
|
||||
var js []byte
|
||||
s := &summarySupport{
|
||||
@@ -72,9 +71,9 @@ func newSummarySupport(summary *models.EntitySummary) (*summarySupport, error) {
|
||||
return s, err
|
||||
}
|
||||
|
||||
func (s summarySupport) toEntitySummary() (*models.EntitySummary, error) {
|
||||
func (s summarySupport) toEntitySummary() (*entity.EntitySummary, error) {
|
||||
var err error
|
||||
summary := &models.EntitySummary{
|
||||
summary := &entity.EntitySummary{
|
||||
Name: s.name,
|
||||
}
|
||||
if s.description != nil {
|
||||
|
||||
Reference in New Issue
Block a user