Chore: Remove pkg/models/stats.go (#61613)

* remove pkg/models/stats.go

* rename models package in tests
This commit is contained in:
Serge Zaitsev
2023-01-17 14:17:54 +01:00
committed by GitHub
parent 1b86a49622
commit efed0151f8
12 changed files with 78 additions and 102 deletions
+5 -28
View File
@@ -9,6 +9,7 @@ import (
"github.com/grafana/grafana/pkg/services/sqlstore"
"github.com/grafana/grafana/pkg/services/sqlstore/migrator"
"github.com/grafana/grafana/pkg/services/sqlstore/session"
"github.com/grafana/grafana/pkg/services/stats"
"github.com/grafana/grafana/pkg/services/team"
"github.com/grafana/grafana/pkg/services/user"
)
@@ -23,10 +24,10 @@ type SQLStoreMock struct {
ExpectedUser *user.User
ExpectedTeamsByUser []*team.TeamDTO
ExpectedAlert *models.Alert
ExpectedSystemStats *models.SystemStats
ExpectedDataSourceStats []*models.DataSourceStats
ExpectedDataSourcesAccessStats []*models.DataSourceAccessStats
ExpectedNotifierUsageStats []*models.NotifierUsageStats
ExpectedSystemStats *stats.SystemStats
ExpectedDataSourceStats []*stats.DataSourceStats
ExpectedDataSourcesAccessStats []*stats.DataSourceAccessStats
ExpectedNotifierUsageStats []*stats.NotifierUsageStats
ExpectedSignedInUser *user.SignedInUser
ExpectedError error
@@ -36,30 +37,6 @@ func NewSQLStoreMock() *SQLStoreMock {
return &SQLStoreMock{}
}
func (m *SQLStoreMock) GetAdminStats(ctx context.Context, query *models.GetAdminStatsQuery) error {
return m.ExpectedError
}
func (m *SQLStoreMock) GetAlertNotifiersUsageStats(ctx context.Context, query *models.GetAlertNotifierUsageStatsQuery) error {
query.Result = m.ExpectedNotifierUsageStats
return m.ExpectedError
}
func (m *SQLStoreMock) GetDataSourceStats(ctx context.Context, query *models.GetDataSourceStatsQuery) error {
query.Result = m.ExpectedDataSourceStats
return m.ExpectedError
}
func (m *SQLStoreMock) GetDataSourceAccessStats(ctx context.Context, query *models.GetDataSourceAccessStatsQuery) error {
query.Result = m.ExpectedDataSourcesAccessStats
return m.ExpectedError
}
func (m *SQLStoreMock) GetSystemStats(ctx context.Context, query *models.GetSystemStatsQuery) error {
query.Result = m.ExpectedSystemStats
return m.ExpectedError
}
func (m *SQLStoreMock) GetDialect() migrator.Dialect {
return nil
}
+2 -2
View File
@@ -24,13 +24,13 @@ import (
"github.com/grafana/grafana/pkg/infra/localcache"
"github.com/grafana/grafana/pkg/infra/log"
"github.com/grafana/grafana/pkg/infra/tracing"
"github.com/grafana/grafana/pkg/models"
"github.com/grafana/grafana/pkg/registry"
"github.com/grafana/grafana/pkg/services/featuremgmt"
"github.com/grafana/grafana/pkg/services/sqlstore/migrations"
"github.com/grafana/grafana/pkg/services/sqlstore/migrator"
"github.com/grafana/grafana/pkg/services/sqlstore/session"
"github.com/grafana/grafana/pkg/services/sqlstore/sqlutil"
"github.com/grafana/grafana/pkg/services/stats"
"github.com/grafana/grafana/pkg/services/user"
"github.com/grafana/grafana/pkg/setting"
"github.com/grafana/grafana/pkg/util"
@@ -202,7 +202,7 @@ func (ss *SQLStore) ensureMainOrgAndAdminUser(test bool) error {
// If this is a test database, don't exit early when any user is found.
if !test {
var stats models.SystemUserCountStats
var stats stats.SystemUserCountStats
// TODO: Should be able to rename "Count" to "count", for more standard SQL style
// Just have to make sure it gets deserialized properly into models.SystemUserCountStats
rawSQL := `SELECT COUNT(id) AS Count FROM ` + ss.Dialect.Quote("user")