mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
SQLStore: Rewrite system statistics query to count users once (#20711)
Fix system statistics query to count only once users that are part of several organisations. Fixes #20681
This commit is contained in:
parent
5cfc681175
commit
02d7d00560
@ -95,12 +95,12 @@ func GetSystemStats(query *m.GetSystemStatsQuery) error {
|
||||
func roleCounterSQL(role, alias string) string {
|
||||
return `
|
||||
(
|
||||
SELECT COUNT(*)
|
||||
SELECT COUNT(DISTINCT u.id)
|
||||
FROM ` + dialect.Quote("user") + ` as u, org_user
|
||||
WHERE ( org_user.user_id=u.id AND org_user.role='` + role + `' )
|
||||
) as ` + alias + `,
|
||||
(
|
||||
SELECT COUNT(*)
|
||||
SELECT COUNT(DISTINCT u.id)
|
||||
FROM ` + dialect.Quote("user") + ` as u, org_user
|
||||
WHERE u.last_seen_at>? AND ( org_user.user_id=u.id AND org_user.role='` + role + `' )
|
||||
) as active_` + alias
|
||||
|
Loading…
Reference in New Issue
Block a user