summaryrefslogtreecommitdiffstats
path: root/store/sql_channel_store.go
diff options
context:
space:
mode:
authorCorey Hulen <corey@hulen.com>2016-01-22 17:00:09 -0600
committerCorey Hulen <corey@hulen.com>2016-01-22 17:00:09 -0600
commit1a0b12313bd0af1724df2fc6260ef284acfc5f93 (patch)
treeaf8cd83e5beba2426251532e42ba059c59af59b9 /store/sql_channel_store.go
parentd352c5b64dddfb8e46b18edbd7352c41495078a1 (diff)
parent60a73ebabba6798d2b45fa8c8ac0f2bfa6144689 (diff)
downloadchat-1a0b12313bd0af1724df2fc6260ef284acfc5f93.tar.gz
chat-1a0b12313bd0af1724df2fc6260ef284acfc5f93.tar.bz2
chat-1a0b12313bd0af1724df2fc6260ef284acfc5f93.zip
Merge pull request #1956 from mattermost/plt-1779
PLT-1779 Add system-wide statistics page
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 {