mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Add quota setting for correlations (#65076)
* Add quota setting for correlations * Fix linter
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
|
||||
"github.com/grafana/grafana/pkg/infra/db"
|
||||
"github.com/grafana/grafana/pkg/services/datasources"
|
||||
"github.com/grafana/grafana/pkg/services/quota"
|
||||
"github.com/grafana/grafana/pkg/util"
|
||||
)
|
||||
|
||||
@@ -177,6 +178,31 @@ func (s CorrelationsService) getCorrelation(ctx context.Context, cmd GetCorrelat
|
||||
return correlation, nil
|
||||
}
|
||||
|
||||
func (s CorrelationsService) CountCorrelations(ctx context.Context) (*quota.Map, error) {
|
||||
u := "a.Map{}
|
||||
var err error
|
||||
count := int64(0)
|
||||
err = s.SQLStore.WithDbSession(ctx, func(sess *db.Session) error {
|
||||
q := sess.Table("correlation")
|
||||
count, err = q.Count()
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
tag, err := quota.NewTag(QuotaTargetSrv, QuotaTarget, quota.GlobalScope)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
u.Set(tag, count)
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return u, err
|
||||
}
|
||||
|
||||
func (s CorrelationsService) getCorrelationsBySourceUID(ctx context.Context, cmd GetCorrelationsBySourceUIDQuery) ([]Correlation, error) {
|
||||
correlations := make([]Correlation, 0)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user