chore: sqlstore cleanup (#60415)

* chore: remove unused test helper from sqlstore

TimeNow() is no longer used in any tests in this package.

* chore: move sqlstore.SQLBuilder to the infra/db package

This required some minor refactoring; we need to be a little more explicit about passing around the dialect and engine. On the other hand, that's a few fewer uses of the `dialect` global constant!

* chore: move UserDeletions into the only package using it

* cleanup around moving sqlbuilder

* remove dialect and sqlog global vars

* rename userDeletions to serviceAccountDeletions
This commit is contained in:
Kristin Laemmert
2022-12-16 11:09:06 -05:00
committed by GitHub
parent d332dab3ec
commit cc007e9727
12 changed files with 67 additions and 88 deletions
+1 -2
View File
@@ -8,7 +8,6 @@ import (
"github.com/grafana/grafana/pkg/infra/db"
"github.com/grafana/grafana/pkg/models"
"github.com/grafana/grafana/pkg/services/org"
"github.com/grafana/grafana/pkg/services/sqlstore"
"github.com/grafana/grafana/pkg/services/sqlstore/migrator"
"github.com/grafana/grafana/pkg/services/stats"
)
@@ -56,7 +55,7 @@ func notServiceAccount(dialect migrator.Dialect) string {
func (ss *sqlStatsService) GetSystemStats(ctx context.Context, query *models.GetSystemStatsQuery) error {
return ss.db.WithDbSession(ctx, func(dbSession *db.Session) error {
sb := &sqlstore.SQLBuilder{}
sb := &db.SQLBuilder{}
sb.Write("SELECT ")
dialect := ss.db.GetDialect()
sb.Write(`(SELECT COUNT(*) FROM ` + dialect.Quote("user") + ` WHERE ` + notServiceAccount(dialect) + `) AS users,`)