diff options
author | =Corey Hulen <corey@hulen.com> | 2016-01-25 11:23:55 -0500 |
---|---|---|
committer | =Corey Hulen <corey@hulen.com> | 2016-01-25 11:23:55 -0500 |
commit | ea71731f838fc010cfc7511c09875184d1b2396b (patch) | |
tree | 7841e6908a42badb5171760426d2ca5898a76bda /store/sql_user_store.go | |
parent | 6b534f1b0dae2614ec267a82f1c4dc1b096b7b1c (diff) | |
parent | 5478ea34e436109ece417c3704a1fa36d3aba4a5 (diff) | |
download | chat-ea71731f838fc010cfc7511c09875184d1b2396b.tar.gz chat-ea71731f838fc010cfc7511c09875184d1b2396b.tar.bz2 chat-ea71731f838fc010cfc7511c09875184d1b2396b.zip |
merging
Diffstat (limited to 'store/sql_user_store.go')
-rw-r--r-- | store/sql_user_store.go | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/store/sql_user_store.go b/store/sql_user_store.go index 0f73f73c3..efd8b7f33 100644 --- a/store/sql_user_store.go +++ b/store/sql_user_store.go @@ -600,3 +600,30 @@ func (us SqlUserStore) PermanentDelete(userId string) StoreChannel { return storeChannel } + +func (us SqlUserStore) AnalyticsUniqueUserCount(teamId string) StoreChannel { + + storeChannel := make(StoreChannel) + + go func() { + result := StoreResult{} + + query := "SELECT COUNT(DISTINCT Email) FROM Users" + + if len(teamId) > 0 { + query += " WHERE TeamId = :TeamId" + } + + v, err := us.GetReplica().SelectInt(query, map[string]interface{}{"TeamId": teamId}) + if err != nil { + result.Err = model.NewAppError("SqlUserStore.AnalyticsUniqueUserCount", "We couldn't get the unique user count", err.Error()) + } else { + result.Data = v + } + + storeChannel <- result + close(storeChannel) + }() + + return storeChannel +} |