Generalize analytics server functions and begin componentizing client analytics controls

Этот коммит содержится в:
JoramWilander
2016-01-21 12:14:17 -05:00
родитель 2fdfdaeff7
Коммит 2a26d85757
9 изменённых файлов: 407 добавлений и 256 удалений

Просмотреть файл

@@ -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
}