diff options
author | hmhealey <harrisonmhealey@gmail.com> | 2015-11-12 11:25:46 -0500 |
---|---|---|
committer | hmhealey <harrisonmhealey@gmail.com> | 2015-11-12 11:25:46 -0500 |
commit | be43522117e637271509cf24244f554a437c0578 (patch) | |
tree | 53b3d49a095efa96fa80592fdc2a5f5257b78058 /store/sql_channel_store.go | |
parent | 13a251a5ee940383e5a026284275b1f31fb476df (diff) | |
download | chat-be43522117e637271509cf24244f554a437c0578.tar.gz chat-be43522117e637271509cf24244f554a437c0578.tar.bz2 chat-be43522117e637271509cf24244f554a437c0578.zip |
Added ChannelExtra.MemberCount field to reflect the actual member count when we truncate the list of members to 20
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) |