summaryrefslogtreecommitdiffstats
path: root/store/sql_user_store.go
diff options
context:
space:
mode:
authorMaxim <mail@potapovmax.com>2015-10-13 10:15:44 +0300
committerMaxim <mail@potapovmax.com>2015-10-13 10:15:44 +0300
commit9d3248ccec89e533527bb86e082ef445c3cdfe7d (patch)
treefea41f942c66a2ae397ed12f1013585bcbf7775c /store/sql_user_store.go
parent53d58fc3374268484a6eb5d8aae2c82719ec782d (diff)
parent0144b6fd8a95c6b65695b07483a528707dce1cfe (diff)
downloadchat-9d3248ccec89e533527bb86e082ef445c3cdfe7d.tar.gz
chat-9d3248ccec89e533527bb86e082ef445c3cdfe7d.tar.bz2
chat-9d3248ccec89e533527bb86e082ef445c3cdfe7d.zip
Merge branch 'master' into PLT-590
Diffstat (limited to 'store/sql_user_store.go')
-rw-r--r--store/sql_user_store.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/store/sql_user_store.go b/store/sql_user_store.go
index 011acd7e4..dc6b07a16 100644
--- a/store/sql_user_store.go
+++ b/store/sql_user_store.go
@@ -530,3 +530,24 @@ func (us SqlUserStore) GetTotalUsersCount() StoreChannel {
return storeChannel
}
+
+func (us SqlUserStore) GetTotalActiveUsersCount() StoreChannel {
+ storeChannel := make(StoreChannel)
+
+ go func() {
+ result := StoreResult{}
+
+ time := model.GetMillis() - (1000 * 60 * 60 * 12)
+
+ if count, err := us.GetReplica().SelectInt("SELECT COUNT(Id) FROM Users WHERE LastActivityAt > :Time", map[string]interface{}{"Time": time}); err != nil {
+ result.Err = model.NewAppError("SqlUserStore.GetTotalActiveUsersCount", "We could not count the users", err.Error())
+ } else {
+ result.Data = count
+ }
+
+ storeChannel <- result
+ close(storeChannel)
+ }()
+
+ return storeChannel
+}