diff options
author | Christopher Speller <crspeller@gmail.com> | 2015-11-12 12:35:47 -0500 |
---|---|---|
committer | Christopher Speller <crspeller@gmail.com> | 2015-11-12 12:35:47 -0500 |
commit | c1ab5adb209cefde121aff308b77e470368422cd (patch) | |
tree | a5f11345a5a0ea2447300eadea59e948e8003c5e /store/sql_channel_store.go | |
parent | 67b92f32481dba243786821ed3eb189c0bd7261d (diff) | |
parent | be43522117e637271509cf24244f554a437c0578 (diff) | |
download | chat-c1ab5adb209cefde121aff308b77e470368422cd.tar.gz chat-c1ab5adb209cefde121aff308b77e470368422cd.tar.bz2 chat-c1ab5adb209cefde121aff308b77e470368422cd.zip |
Merge pull request #1410 from hmhealey/plt906
PLT-906 Added ChannelExtra.MemberCount field
Diffstat (limited to 'store/sql_channel_store.go')
-rw-r--r-- | store/sql_channel_store.go | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/store/sql_channel_store.go b/store/sql_channel_store.go index fc4e19442..a9f99bd67 100644 --- a/store/sql_channel_store.go +++ b/store/sql_channel_store.go @@ -542,6 +542,26 @@ func (s SqlChannelStore) GetMember(channelId string, userId string) StoreChannel return storeChannel } +func (s SqlChannelStore) GetMemberCount(channelId string) StoreChannel { + storeChannel := make(StoreChannel) + + go func() { + result := StoreResult{} + + count, err := s.GetReplica().SelectInt("SELECT count(*) FROM ChannelMembers WHERE ChannelId = :ChannelId", map[string]interface{}{"ChannelId": channelId}) + if err != nil { + result.Err = model.NewAppError("SqlChannelStore.GetMemberCount", "We couldn't get the channel member count", "channel_id="+channelId+", "+err.Error()) + } else { + result.Data = count + } + + storeChannel <- result + close(storeChannel) + }() + + return storeChannel +} + func (s SqlChannelStore) GetExtraMembers(channelId string, limit int) StoreChannel { storeChannel := make(StoreChannel) |