summaryrefslogtreecommitdiffstats
path: root/store/sql_channel_store.go
diff options
context:
space:
mode:
authorJoramWilander <jwawilander@gmail.com>2016-01-21 12:14:17 -0500
committerJoramWilander <jwawilander@gmail.com>2016-01-21 12:14:23 -0500
commit2a26d857574f2160e3ee5538ad3a84ec47082f86 (patch)
treef7a253736eb21ecc1f4f93f95741405da7fa0321 /store/sql_channel_store.go
parent2fdfdaeff7a0bf29fd21eec6d4f48abe579d5048 (diff)
downloadchat-2a26d857574f2160e3ee5538ad3a84ec47082f86.tar.gz
chat-2a26d857574f2160e3ee5538ad3a84ec47082f86.tar.bz2
chat-2a26d857574f2160e3ee5538ad3a84ec47082f86.zip
Generalize analytics server functions and begin componentizing client analytics controls
Diffstat (limited to 'store/sql_channel_store.go')
-rw-r--r--store/sql_channel_store.go16
1 files changed, 7 insertions, 9 deletions
diff --git a/store/sql_channel_store.go b/store/sql_channel_store.go
index 4585647de..336398ae7 100644
--- a/store/sql_channel_store.go
+++ b/store/sql_channel_store.go
@@ -869,15 +869,13 @@ func (s SqlChannelStore) AnalyticsTypeCount(teamId string, channelType string) S
go func() {
result := StoreResult{}
- v, err := s.GetReplica().SelectInt(
- `SELECT
- COUNT(Id) AS Value
- FROM
- Channels
- WHERE
- TeamId = :TeamId
- AND Type = :ChannelType`,
- map[string]interface{}{"TeamId": teamId, "ChannelType": channelType})
+ query := "SELECT COUNT(Id) AS Value FROM Channels WHERE Type = :ChannelType"
+
+ if len(teamId) > 0 {
+ query += " AND TeamId = :TeamId"
+ }
+
+ v, err := s.GetReplica().SelectInt(query, map[string]interface{}{"TeamId": teamId, "ChannelType": channelType})
if err != nil {
result.Err = model.NewAppError("SqlChannelStore.AnalyticsTypeCount", "We couldn't get channel type counts", err.Error())
} else {