From ae5d1898037be4f59bf6517ad76b13cc16f595ce Mon Sep 17 00:00:00 2001 From: =Corey Hulen Date: Thu, 22 Oct 2015 18:04:06 -0700 Subject: Adding analytics tab --- store/sql_channel_store.go | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'store/sql_channel_store.go') 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 +} -- cgit v1.2.3-1-g7c22