From 2190392e052221905eba1b6f164ddc9574d92c9a Mon Sep 17 00:00:00 2001 From: utkarshcmu Date: Mon, 25 Jan 2016 00:39:31 -0800 Subject: [PATCH] Added grafana_admins count --- docs/sources/reference/http_api.md | 3 ++- pkg/models/stats.go | 17 +++++++++-------- pkg/services/sqlstore/stats.go | 6 +++++- public/app/features/admin/partials/stats.html | 11 +++++++++-- 4 files changed, 25 insertions(+), 12 deletions(-) diff --git a/docs/sources/reference/http_api.md b/docs/sources/reference/http_api.md index a7ae066a8db..4b0dff6c4b6 100644 --- a/docs/sources/reference/http_api.md +++ b/docs/sources/reference/http_api.md @@ -1446,7 +1446,8 @@ Keys: "db_tag_count":6, "data_source_count":1, "playlist_count":1, - "starred_db_count":2 + "starred_db_count":2, + "grafana_admin_count":2 } ### Global Users diff --git a/pkg/models/stats.go b/pkg/models/stats.go index 6d8618d6ddf..4b1d863d1d2 100644 --- a/pkg/models/stats.go +++ b/pkg/models/stats.go @@ -20,14 +20,15 @@ type GetDataSourceStatsQuery struct { } type AdminStats struct { - UserCount int `json:"user_count"` - OrgCount int `json:"org_count"` - DashboardCount int `json:"dashboard_count"` - DbSnapshotCount int `json:"db_snapshot_count"` - DbTagCount int `json:"db_tag_count"` - DataSourceCount int `json:"data_source_count"` - PlaylistCount int `json:"playlist_count"` - StarredDbCount int `json:"starred_db_count"` + UserCount int `json:"user_count"` + OrgCount int `json:"org_count"` + DashboardCount int `json:"dashboard_count"` + DbSnapshotCount int `json:"db_snapshot_count"` + DbTagCount int `json:"db_tag_count"` + DataSourceCount int `json:"data_source_count"` + PlaylistCount int `json:"playlist_count"` + StarredDbCount int `json:"starred_db_count"` + GrafanaAdminCount int `json:"grafana_admin_count"` } type GetAdminStatsQuery struct { diff --git a/pkg/services/sqlstore/stats.go b/pkg/services/sqlstore/stats.go index 3c9325fa149..ad1d87299b1 100644 --- a/pkg/services/sqlstore/stats.go +++ b/pkg/services/sqlstore/stats.go @@ -81,7 +81,11 @@ func GetAdminStats(query *m.GetAdminStatsQuery) error { ( SELECT COUNT (DISTINCT ` + dialect.Quote("dashboard_id") + ` ) FROM ` + dialect.Quote("star") + ` - ) AS starred_db_count + ) AS starred_db_count, + ( + SELECT SUM ( ` + dialect.Quote("is_admin") + ` ) + FROM ` + dialect.Quote("user") + ` + ) AS grafana_admin_count ` var stats m.AdminStats diff --git a/public/app/features/admin/partials/stats.html b/public/app/features/admin/partials/stats.html index 0df6d251f5c..3743b0c81b8 100644 --- a/public/app/features/admin/partials/stats.html +++ b/public/app/features/admin/partials/stats.html @@ -1,10 +1,13 @@ - + +

- Stats + Overview

@@ -23,6 +26,10 @@ + + + +
Total users {{stats.user_count}}
Total grafana admins{{stats.grafana_admin_count}}
Total organizations {{stats.org_count}}