summaryrefslogtreecommitdiffstats
path: root/store/sql_channel_store.go
diff options
context:
space:
mode:
author=Corey Hulen <corey@hulen.com>2015-10-22 18:04:06 -0700
committer=Corey Hulen <corey@hulen.com>2015-10-22 18:04:06 -0700
commitae5d1898037be4f59bf6517ad76b13cc16f595ce (patch)
tree17c021c2e2a6d785ac3618b6c302742e00978207 /store/sql_channel_store.go
parent649f42e3fc706f8fa829276bcdb825381bc703f2 (diff)
downloadchat-ae5d1898037be4f59bf6517ad76b13cc16f595ce.tar.gz
chat-ae5d1898037be4f59bf6517ad76b13cc16f595ce.tar.bz2
chat-ae5d1898037be4f59bf6517ad76b13cc16f595ce.zip
Adding analytics tab
Diffstat (limited to 'store/sql_channel_store.go')
-rw-r--r--store/sql_channel_store.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/store/sql_channel_store.go b/store/sql_channel_store.go
index 56e190fee..4b30f646e 100644
--- a/store/sql_channel_store.go
+++ b/store/sql_channel_store.go
@@ -744,3 +744,31 @@ func (s SqlChannelStore) GetForExport(teamId string) StoreChannel {
return storeChannel
}
+
+func (s SqlChannelStore) AnalyticsTypeCount(teamId string, channelType string) StoreChannel {
+ storeChannel := make(StoreChannel)
+
+ 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})
+ if err != nil {
+ result.Err = model.NewAppError("SqlChannelStore.AnalyticsTypeCount", "We couldn't get channel type counts", err.Error())
+ } else {
+ result.Data = v
+ }
+
+ storeChannel <- result
+ close(storeChannel)
+ }()
+
+ return storeChannel
+}