diff options
Diffstat (limited to 'store/sql_channel_store.go')
-rw-r--r-- | store/sql_channel_store.go | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/store/sql_channel_store.go b/store/sql_channel_store.go index e7501ae69..068692074 100644 --- a/store/sql_channel_store.go +++ b/store/sql_channel_store.go @@ -1362,6 +1362,32 @@ func (s SqlChannelStore) AnalyticsTypeCount(teamId string, channelType string) S return storeChannel } +func (s SqlChannelStore) AnalyticsDeletedTypeCount(teamId string, channelType string) StoreChannel { + storeChannel := make(StoreChannel, 1) + + go func() { + result := StoreResult{} + + query := "SELECT COUNT(Id) AS Value FROM Channels WHERE Type = :ChannelType AND DeleteAt > 0" + + 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.NewLocAppError("SqlChannelStore.AnalyticsDeletedTypeCount", "store.sql_channel.analytics_deleted_type_count.app_error", nil, err.Error()) + } else { + result.Data = v + } + + storeChannel <- result + close(storeChannel) + }() + + return storeChannel +} + func (s SqlChannelStore) ExtraUpdateByUser(userId string, time int64) StoreChannel { storeChannel := make(StoreChannel, 1) @@ -1546,6 +1572,7 @@ func (s SqlChannelStore) GetMembersByIds(channelId string, userIds []string) Sto result.Err = model.NewLocAppError("SqlChannelStore.GetMembersByIds", "store.sql_channel.get_members_by_ids.app_error", nil, "channelId="+channelId+" "+err.Error()) } else { result.Data = &members + } storeChannel <- result |