add usage stats for datasource access mode
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
||||
func init() {
|
||||
bus.AddHandler("sql", GetSystemStats)
|
||||
bus.AddHandler("sql", GetDataSourceStats)
|
||||
bus.AddHandler("sql", GetDataSourceAccessStats)
|
||||
bus.AddHandler("sql", GetAdminStats)
|
||||
bus.AddHandler("sql", GetSystemUserCountStats)
|
||||
}
|
||||
@@ -23,6 +24,13 @@ func GetDataSourceStats(query *m.GetDataSourceStatsQuery) error {
|
||||
return err
|
||||
}
|
||||
|
||||
func GetDataSourceAccessStats(query *m.GetDataSourceAccessStatsQuery) error {
|
||||
var rawSql = `SELECT COUNT(*) as count, type, access FROM data_source GROUP BY type, access`
|
||||
query.Result = make([]*m.DataSourceAccessStats, 0)
|
||||
err := x.SQL(rawSql).Find(&query.Result)
|
||||
return err
|
||||
}
|
||||
|
||||
func GetSystemStats(query *m.GetSystemStatsQuery) error {
|
||||
var rawSql = `SELECT
|
||||
(
|
||||
|
||||
@@ -23,5 +23,17 @@ func TestStatsDataAccess(t *testing.T) {
|
||||
err := GetSystemUserCountStats(&query)
|
||||
So(err, ShouldBeNil)
|
||||
})
|
||||
|
||||
Convey("Get datasource stats should not results in error", func() {
|
||||
query := m.GetDataSourceStatsQuery{}
|
||||
err := GetDataSourceStats(&query)
|
||||
So(err, ShouldBeNil)
|
||||
})
|
||||
|
||||
Convey("Get datasource access stats should not results in error", func() {
|
||||
query := m.GetDataSourceAccessStatsQuery{}
|
||||
err := GetDataSourceAccessStats(&query)
|
||||
So(err, ShouldBeNil)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user