|
|
|
@ -512,6 +512,7 @@ func (d *dashboardStore) GetDashboardsByPluginID(ctx context.Context, query *das |
|
|
|
|
} |
|
|
|
|
return dashboards, nil |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (d *dashboardStore) GetSoftDeletedDashboard(ctx context.Context, orgID int64, uid string) (*dashboards.Dashboard, error) { |
|
|
|
|
if orgID == 0 || uid == "" { |
|
|
|
|
return nil, dashboards.ErrDashboardIdentifierNotSet |
|
|
|
@ -736,7 +737,7 @@ func createEntityEvent(dashboard *dashboards.Dashboard, eventType store.EntityEv |
|
|
|
|
|
|
|
|
|
func (d *dashboardStore) GetDashboard(ctx context.Context, query *dashboards.GetDashboardQuery) (*dashboards.Dashboard, error) { |
|
|
|
|
var queryResult *dashboards.Dashboard |
|
|
|
|
err := d.store.DB().WithDbSession(ctx, func(sess *db.Session) error { |
|
|
|
|
err := d.store.ReadReplica().WithDbSession(ctx, func(sess *db.Session) error { |
|
|
|
|
metrics.MFolderIDsServiceCount.WithLabelValues(metrics.Dashboard).Inc() |
|
|
|
|
// nolint:staticcheck
|
|
|
|
|
if query.ID == 0 && len(query.UID) == 0 && (query.Title == nil || (query.FolderID == nil && query.FolderUID == nil)) { |
|
|
|
@ -796,7 +797,7 @@ func (d *dashboardStore) GetDashboardUIDByID(ctx context.Context, query *dashboa |
|
|
|
|
|
|
|
|
|
func (d *dashboardStore) GetDashboards(ctx context.Context, query *dashboards.GetDashboardsQuery) ([]*dashboards.Dashboard, error) { |
|
|
|
|
var dashboards = make([]*dashboards.Dashboard, 0) |
|
|
|
|
err := d.store.DB().WithDbSession(ctx, func(sess *db.Session) error { |
|
|
|
|
err := d.store.ReadReplica().WithDbSession(ctx, func(sess *db.Session) error { |
|
|
|
|
if len(query.DashboardIDs) == 0 && len(query.DashboardUIDs) == 0 { |
|
|
|
|
return star.ErrCommandValidationFailed |
|
|
|
|
} |
|
|
|
@ -823,7 +824,7 @@ func (d *dashboardStore) GetDashboards(ctx context.Context, query *dashboards.Ge |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (d *dashboardStore) FindDashboards(ctx context.Context, query *dashboards.FindPersistedDashboardsQuery) ([]dashboards.DashboardSearchProjection, error) { |
|
|
|
|
recursiveQueriesAreSupported, err := d.store.DB().RecursiveQueriesAreSupported() |
|
|
|
|
recursiveQueriesAreSupported, err := d.store.ReadReplica().RecursiveQueriesAreSupported() |
|
|
|
|
if err != nil { |
|
|
|
|
return nil, err |
|
|
|
|
} |
|
|
|
@ -856,11 +857,11 @@ func (d *dashboardStore) FindDashboards(ctx context.Context, query *dashboards.F |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if len(query.Title) > 0 { |
|
|
|
|
filters = append(filters, searchstore.TitleFilter{Dialect: d.store.DB().GetDialect(), Title: query.Title}) |
|
|
|
|
filters = append(filters, searchstore.TitleFilter{Dialect: d.store.ReadReplica().GetDialect(), Title: query.Title}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if len(query.Type) > 0 { |
|
|
|
|
filters = append(filters, searchstore.TypeFilter{Dialect: d.store.DB().GetDialect(), Type: query.Type}) |
|
|
|
|
filters = append(filters, searchstore.TypeFilter{Dialect: d.store.ReadReplica().GetDialect(), Type: query.Type}) |
|
|
|
|
} |
|
|
|
|
metrics.MFolderIDsServiceCount.WithLabelValues(metrics.Dashboard).Inc() |
|
|
|
|
// nolint:staticcheck
|
|
|
|
@ -870,7 +871,7 @@ func (d *dashboardStore) FindDashboards(ctx context.Context, query *dashboards.F |
|
|
|
|
|
|
|
|
|
if len(query.FolderUIDs) > 0 { |
|
|
|
|
filters = append(filters, searchstore.FolderUIDFilter{ |
|
|
|
|
Dialect: d.store.DB().GetDialect(), |
|
|
|
|
Dialect: d.store.ReadReplica().GetDialect(), |
|
|
|
|
OrgID: orgID, |
|
|
|
|
UIDs: query.FolderUIDs, |
|
|
|
|
NestedFoldersEnabled: d.features.IsEnabled(ctx, featuremgmt.FlagNestedFolders), |
|
|
|
@ -887,7 +888,7 @@ func (d *dashboardStore) FindDashboards(ctx context.Context, query *dashboards.F |
|
|
|
|
filters = append(filters, searchstore.DeletedFilter{Deleted: query.IsDeleted}) |
|
|
|
|
|
|
|
|
|
var res []dashboards.DashboardSearchProjection |
|
|
|
|
sb := &searchstore.Builder{Dialect: d.store.DB().GetDialect(), Filters: filters, Features: d.features} |
|
|
|
|
sb := &searchstore.Builder{Dialect: d.store.ReadReplica().GetDialect(), Filters: filters, Features: d.features} |
|
|
|
|
|
|
|
|
|
limit := query.Limit |
|
|
|
|
if limit < 1 { |
|
|
|
@ -901,7 +902,7 @@ func (d *dashboardStore) FindDashboards(ctx context.Context, query *dashboards.F |
|
|
|
|
|
|
|
|
|
sql, params := sb.ToSQL(limit, page) |
|
|
|
|
|
|
|
|
|
err = d.store.DB().WithDbSession(ctx, func(sess *db.Session) error { |
|
|
|
|
err = d.store.ReadReplica().WithDbSession(ctx, func(sess *db.Session) error { |
|
|
|
|
return sess.SQL(sql, params...).Find(&res) |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
@ -993,7 +994,7 @@ func (d *dashboardStore) DeleteDashboardsInFolders( |
|
|
|
|
|
|
|
|
|
func (d *dashboardStore) GetAllDashboards(ctx context.Context) ([]*dashboards.Dashboard, error) { |
|
|
|
|
var dashboards = make([]*dashboards.Dashboard, 0) |
|
|
|
|
err := d.store.DB().WithDbSession(ctx, func(session *db.Session) error { |
|
|
|
|
err := d.store.ReadReplica().WithDbSession(ctx, func(session *db.Session) error { |
|
|
|
|
err := session.Find(&dashboards) |
|
|
|
|
return err |
|
|
|
|
}) |
|
|
|
|