MM-44088: Add teamID filter to channelMembers (#20176)
We add 2 new params to channel members query. 1. Filter by teamId. 2. Negate that filter. We include some more optimizations like: - Moved the team role checks inside the dataloader. - Moved the channel pretty name computation inside the loader. Now that we load less data on initial load, we can reduce the concurrency requirement to be a bit on the safer side. ```release-note NONE ```
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
5ac3dbf058
Коммит
a6d8e45297
@@ -2814,7 +2814,7 @@ func (s SqlChannelStore) GetMembersForUser(teamID string, userID string) (model.
|
||||
return dbMembers.ToModel(), nil
|
||||
}
|
||||
|
||||
func (s SqlChannelStore) GetMembersForUserWithCursor(userID, afterChannel, afterUser string, limit, lastUpdateAt int) (model.ChannelMembers, error) {
|
||||
func (s SqlChannelStore) GetMembersForUserWithCursor(userID, teamID string, opts *store.ChannelMemberGraphQLSearchOpts) (model.ChannelMembers, error) {
|
||||
query := s.getQueryBuilder().
|
||||
Select("ChannelMembers.*",
|
||||
"TeamScheme.DefaultChannelGuestRole TeamSchemeDefaultGuestRole",
|
||||
@@ -2834,20 +2834,36 @@ func (s SqlChannelStore) GetMembersForUserWithCursor(userID, afterChannel, after
|
||||
}).
|
||||
OrderBy("ChannelId, UserId ASC").
|
||||
// The limit is verified at the GraphQL layer.
|
||||
Limit(uint64(limit))
|
||||
Limit(uint64(opts.Limit))
|
||||
|
||||
if afterChannel != "" && afterUser != "" {
|
||||
if teamID != "" {
|
||||
if opts.ExcludeTeam {
|
||||
// Exclude this team and DM/GMs
|
||||
query = query.Where(sq.And{
|
||||
sq.NotEq{"Channels.TeamId": teamID},
|
||||
sq.NotEq{"Channels.TeamId": ""},
|
||||
})
|
||||
} else {
|
||||
// Include this team and DM/GMs
|
||||
query = query.Where(sq.Or{
|
||||
sq.Eq{"Channels.TeamId": teamID},
|
||||
sq.Eq{"Channels.TeamId": ""},
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
if opts.AfterChannel != "" && opts.AfterUser != "" {
|
||||
query = query.Where(sq.Or{
|
||||
sq.Gt{"ChannelMembers.ChannelId": afterChannel},
|
||||
sq.Gt{"ChannelMembers.ChannelId": opts.AfterChannel},
|
||||
sq.And{
|
||||
sq.Eq{"ChannelMembers.ChannelId": afterChannel},
|
||||
sq.Gt{"ChannelMembers.UserId": afterUser},
|
||||
sq.Eq{"ChannelMembers.ChannelId": opts.AfterChannel},
|
||||
sq.Gt{"ChannelMembers.UserId": opts.AfterUser},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
if lastUpdateAt != 0 {
|
||||
query = query.Where(sq.GtOrEq{"ChannelMembers.LastUpdateAt": lastUpdateAt})
|
||||
if opts.LastUpdateAt != 0 {
|
||||
query = query.Where(sq.GtOrEq{"ChannelMembers.LastUpdateAt": opts.LastUpdateAt})
|
||||
}
|
||||
|
||||
queryString, args, err := query.ToSql()
|
||||
|
||||
Ссылка в новой задаче
Block a user