diff options
Diffstat (limited to 'store')
-rw-r--r-- | store/sql_user_store.go | 25 | ||||
-rw-r--r-- | store/store.go | 1 |
2 files changed, 26 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) diff --git a/store/store.go b/store/store.go index 88a553b7c..730a923c5 100644 --- a/store/store.go +++ b/store/store.go @@ -175,6 +175,7 @@ type UserStore interface { GetSystemAdminProfiles() StoreChannel PermanentDelete(userId string) StoreChannel AnalyticsUniqueUserCount(teamId string) StoreChannel + AnalyticsActiveCount(time int64) StoreChannel GetUnreadCount(userId string) StoreChannel GetUnreadCountForChannel(userId string, channelId string) StoreChannel GetRecentlyActiveUsersForTeam(teamId string) StoreChannel |