summaryrefslogtreecommitdiffstats
path: root/store/sql_user_store.go
diff options
context:
space:
mode:
authorGeorge Goldberg <george@gberg.me>2017-02-24 17:33:59 +0000
committerGitHub <noreply@github.com>2017-02-24 17:33:59 +0000
commitf182d196fffc9da89ad63bdbd7bbb2e41da3146e (patch)
tree45d8aaad6ffc335dd40db225f2775d3204fcc812 /store/sql_user_store.go
parentba028ed74b69bd1dd902344663fbf8ba4f1dfb87 (diff)
downloadchat-f182d196fffc9da89ad63bdbd7bbb2e41da3146e.tar.gz
chat-f182d196fffc9da89ad63bdbd7bbb2e41da3146e.tar.bz2
chat-f182d196fffc9da89ad63bdbd7bbb2e41da3146e.zip
PLT-5070: Server side component of Telemetry. (#5514)
Diffstat (limited to 'store/sql_user_store.go')
-rw-r--r--store/sql_user_store.go39
1 files changed, 39 insertions, 0 deletions
diff --git a/store/sql_user_store.go b/store/sql_user_store.go
index 68c1ffec7..a2a9c8347 100644
--- a/store/sql_user_store.go
+++ b/store/sql_user_store.go
@@ -1438,3 +1438,42 @@ func (us SqlUserStore) performSearch(searchQuery string, term string, options ma
return result
}
+
+func (us SqlUserStore) AnalyticsGetInactiveUsersCount() StoreChannel {
+ storeChannel := make(StoreChannel, 1)
+
+ go func() {
+ result := StoreResult{}
+
+ if count, err := us.GetReplica().SelectInt("SELECT COUNT(Id) FROM Users WHERE DeleteAt > 0"); err != nil {
+ result.Err = model.NewLocAppError("SqlUserStore.AnalyticsGetInactiveUsersCount", "store.sql_user.analytics_get_inactive_users_count.app_error", nil, err.Error())
+ } else {
+ result.Data = count
+ }
+
+ storeChannel <- result
+ close(storeChannel)
+ }()
+
+ return storeChannel
+}
+
+func (us SqlUserStore) AnalyticsGetSystemAdminCount() StoreChannel {
+
+ storeChannel := make(StoreChannel, 1)
+
+ go func() {
+ result := StoreResult{}
+
+ if count, err := us.GetReplica().SelectInt("SELECT count(*) FROM Users WHERE Roles LIKE :Roles and DeleteAt = 0", map[string]interface{}{"Roles": "%system_admin%"}); err != nil {
+ result.Err = model.NewLocAppError("SqlUserStore.AnalyticsGetSystemAdminCount", "store.sql_user.analytics_get_system_admin_count.app_error", nil, err.Error())
+ } else {
+ result.Data = count
+ }
+
+ storeChannel <- result
+ close(storeChannel)
+ }()
+
+ return storeChannel
+}