bus: dont mix ctx/classic handlers
This commit is contained in:
@@ -13,8 +13,7 @@ func init() {
|
||||
bus.AddHandler("sql", GetDataSourceStats)
|
||||
bus.AddHandler("sql", GetDataSourceAccessStats)
|
||||
bus.AddHandler("sql", GetAdminStats)
|
||||
bus.AddHandler("sql", GetSystemUserCountStats)
|
||||
bus.AddHandlerCtx("sql", GetSystemUserCountStatsCtx)
|
||||
bus.AddHandlerCtx("sql", GetSystemUserCountStats)
|
||||
}
|
||||
|
||||
var activeUserTimeLimit = time.Hour * 24 * 30
|
||||
@@ -135,7 +134,7 @@ func GetAdminStats(query *m.GetAdminStatsQuery) error {
|
||||
return err
|
||||
}
|
||||
|
||||
func GetSystemUserCountStatsCtx(ctx context.Context, query *m.GetSystemUserCountStatsQuery) error {
|
||||
func GetSystemUserCountStats(ctx context.Context, query *m.GetSystemUserCountStatsQuery) error {
|
||||
return withDbSession(ctx, func(sess *DBSession) error {
|
||||
|
||||
var rawSql = `SELECT COUNT(id) AS Count FROM ` + dialect.Quote("user")
|
||||
@@ -150,16 +149,3 @@ func GetSystemUserCountStatsCtx(ctx context.Context, query *m.GetSystemUserCount
|
||||
return err
|
||||
})
|
||||
}
|
||||
|
||||
func GetSystemUserCountStats(query *m.GetSystemUserCountStatsQuery) error {
|
||||
var rawSql = `SELECT COUNT(id) AS Count FROM ` + dialect.Quote("user")
|
||||
var stats m.SystemUserCountStats
|
||||
_, err := x.SQL(rawSql).Get(&stats)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
query.Result = &stats
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package sqlstore
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
m "github.com/grafana/grafana/pkg/models"
|
||||
@@ -20,7 +21,7 @@ func TestStatsDataAccess(t *testing.T) {
|
||||
|
||||
Convey("Get system user count stats should not results in error", func() {
|
||||
query := m.GetSystemUserCountStatsQuery{}
|
||||
err := GetSystemUserCountStats(&query)
|
||||
err := GetSystemUserCountStats(context.Background(), &query)
|
||||
So(err, ShouldBeNil)
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user