mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
* Add features dependency to SQLBuilder * Add features dependency to AccessControlDashboardPermissionFilter * Add test for folder inheritance * Dashboard permissions: Return recursive query * Recursive query for inherited folders * Modify search builder * Adjust db.SQLBuilder * Pass flag to SQLbuilder if CTEs are supported * Add support for mysql < 8.0 * Add benchmarking for search with nested folders * Set features to AlertStore * Update pkg/infra/db/sqlbuilder.go Co-authored-by: Ieva <ieva.vasiljeva@grafana.com> * Set features to LibraryElementService * SQLBuilder tests with nested folder flag set * Apply suggestion from code review Co-authored-by: IevaVasiljeva <ieva.vasiljeva@grafana.com> Co-authored-by: Emil Tullstedt <emil.tullstedt@grafana.com>
56 lines
1.7 KiB
Go
56 lines
1.7 KiB
Go
package annotationsimpl
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/grafana/grafana/pkg/infra/db"
|
|
"github.com/grafana/grafana/pkg/infra/log"
|
|
"github.com/grafana/grafana/pkg/services/annotations"
|
|
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
|
"github.com/grafana/grafana/pkg/services/tag"
|
|
"github.com/grafana/grafana/pkg/setting"
|
|
)
|
|
|
|
type RepositoryImpl struct {
|
|
store store
|
|
}
|
|
|
|
func ProvideService(db db.DB, cfg *setting.Cfg, features featuremgmt.FeatureToggles, tagService tag.Service) *RepositoryImpl {
|
|
return &RepositoryImpl{
|
|
store: &xormRepositoryImpl{
|
|
cfg: cfg,
|
|
features: features,
|
|
db: db,
|
|
log: log.New("annotations"),
|
|
tagService: tagService,
|
|
maximumTagsLength: cfg.AnnotationMaximumTagsLength,
|
|
},
|
|
}
|
|
}
|
|
|
|
func (r *RepositoryImpl) Save(ctx context.Context, item *annotations.Item) error {
|
|
return r.store.Add(ctx, item)
|
|
}
|
|
|
|
// SaveMany inserts multiple annotations at once.
|
|
// It does not return IDs associated with created annotations. If you need this functionality, use the single-item Save instead.
|
|
func (r *RepositoryImpl) SaveMany(ctx context.Context, items []annotations.Item) error {
|
|
return r.store.AddMany(ctx, items)
|
|
}
|
|
|
|
func (r *RepositoryImpl) Update(ctx context.Context, item *annotations.Item) error {
|
|
return r.store.Update(ctx, item)
|
|
}
|
|
|
|
func (r *RepositoryImpl) Find(ctx context.Context, query *annotations.ItemQuery) ([]*annotations.ItemDTO, error) {
|
|
return r.store.Get(ctx, query)
|
|
}
|
|
|
|
func (r *RepositoryImpl) Delete(ctx context.Context, params *annotations.DeleteParams) error {
|
|
return r.store.Delete(ctx, params)
|
|
}
|
|
|
|
func (r *RepositoryImpl) FindTags(ctx context.Context, query *annotations.TagsQuery) (annotations.FindTagsResult, error) {
|
|
return r.store.GetTags(ctx, query)
|
|
}
|