From 61f92517f317f4b3f437b8db48f31c569ceb5f2d Mon Sep 17 00:00:00 2001 From: =Corey Hulen Date: Fri, 9 Oct 2015 12:24:39 -0700 Subject: PLT-586 fixing issues with security alert --- store/sql_user_store.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'store/sql_user_store.go') 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 +} -- cgit v1.2.3-1-g7c22