summaryrefslogtreecommitdiffstats
path: root/store/sql_user_store.go
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2017-01-20 15:24:53 -0500
committerenahum <nahumhbl@gmail.com>2017-01-20 17:24:53 -0300
commit11a688d3813646aeb97f58b61c083b019da66cfc (patch)
tree2d1c7085837505fb49ecba4dd49c8a34b0a5888c /store/sql_user_store.go
parent66dddbdb7895a87e858f9238e546cedc6e05e34e (diff)
downloadchat-11a688d3813646aeb97f58b61c083b019da66cfc.tar.gz
chat-11a688d3813646aeb97f58b61c083b019da66cfc.tar.bz2
chat-11a688d3813646aeb97f58b61c083b019da66cfc.zip
Adding active users statistics to system console (#5141)
Diffstat (limited to 'store/sql_user_store.go')
-rw-r--r--store/sql_user_store.go25
1 files changed, 25 insertions, 0 deletions
diff --git a/store/sql_user_store.go b/store/sql_user_store.go
index 533757479..09742a4f4 100644
--- a/store/sql_user_store.go
+++ b/store/sql_user_store.go
@@ -1129,6 +1129,31 @@ func (us SqlUserStore) AnalyticsUniqueUserCount(teamId string) StoreChannel {
return storeChannel
}
+func (us SqlUserStore) AnalyticsActiveCount(timePeriod int64) StoreChannel {
+
+ storeChannel := make(StoreChannel, 1)
+
+ go func() {
+ result := StoreResult{}
+
+ time := model.GetMillis() - timePeriod
+
+ query := "SELECT COUNT(*) FROM Status WHERE LastActivityAt > :Time"
+
+ v, err := us.GetReplica().SelectInt(query, map[string]interface{}{"Time": time})
+ if err != nil {
+ result.Err = model.NewLocAppError("SqlUserStore.AnalyticsDailyActiveUsers", "store.sql_user.analytics_daily_active_users.app_error", nil, err.Error())
+ } else {
+ result.Data = v
+ }
+
+ storeChannel <- result
+ close(storeChannel)
+ }()
+
+ return storeChannel
+}
+
func (us SqlUserStore) GetUnreadCount(userId string) StoreChannel {
storeChannel := make(StoreChannel, 1)