MM42267: Add member count in the browse channel modal (#23800)
* add base for calling the endpoint * add endpoint and handler * update store and layers * call the endpoint * align types * update app layers * generate mocks * complete handler * finish store query * add todos * add ui for member count * add selector * add a todo * add cache layer * optimize calls in FE * handle invalidation of the cache * fix go style * fix test * use existing channel layer count * fix import error * delete unnecessary code * write tests for channel cache layer * fix testname * fix mocks * fix cache layer test * fix a test * really fix the test * write more tests for server * address PR comments * remove comment * rename more_channels to browse_channels * fix style * update snapshot * add translations * Revert "add translations" This reverts commit 56476a5dabe357703ef02be9a38b3e88f5c8b1e7. * add only related translations * address PR review points * add test * fix test --------- Co-authored-by: Mattermost Build <build@mattermost.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
4803889158
Коммит
628273d98d
@@ -2207,6 +2207,47 @@ func (s SqlChannelStore) GetAllChannelMembersForUser(userId string, allowFromCac
|
||||
return ids, nil
|
||||
}
|
||||
|
||||
func (s SqlChannelStore) GetChannelsMemberCount(channelIDs []string) (_ map[string]int64, err error) {
|
||||
query := s.getQueryBuilder().
|
||||
Select("ChannelMembers.ChannelId,COUNT(*) AS Count").
|
||||
From("ChannelMembers").
|
||||
InnerJoin("Users ON ChannelMembers.UserId = Users.Id").
|
||||
Where(sq.And{
|
||||
sq.Eq{"ChannelMembers.ChannelId": channelIDs},
|
||||
sq.Eq{"Users.DeleteAt": 0},
|
||||
}).
|
||||
GroupBy("ChannelMembers.ChannelId")
|
||||
|
||||
queryString, args, err := query.ToSql()
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "channels_member_count_tosql")
|
||||
}
|
||||
|
||||
rows, err := s.GetReplicaX().DB.Query(queryString, args...)
|
||||
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to fetch member counts")
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
memberCounts := make(map[string]int64)
|
||||
for rows.Next() {
|
||||
var channelID string
|
||||
var count int64
|
||||
errScan := rows.Scan(&channelID, &count)
|
||||
if errScan != nil {
|
||||
return nil, errors.Wrap(err, "failed to scan row")
|
||||
}
|
||||
memberCounts[channelID] = count
|
||||
}
|
||||
|
||||
if err = rows.Err(); err != nil {
|
||||
return nil, errors.Wrap(err, "error while iterating rows")
|
||||
}
|
||||
|
||||
return memberCounts, nil
|
||||
}
|
||||
|
||||
func (s SqlChannelStore) InvalidateCacheForChannelMembersNotifyProps(channelId string) {
|
||||
allChannelMembersNotifyPropsForChannelCache.Remove(channelId)
|
||||
if s.metrics != nil {
|
||||
|
||||
Ссылка в новой задаче
Block a user