[MM-16658] Migrate User.GetProfilesInChannel to Sync by default #11462 (#11685)

* Migrate User.GetProfilesInChannel to Sync by default #11462

* Refactor variable names #11462
Этот коммит содержится в:
Taufiq Rahman
2019-07-26 17:11:13 +06:00
коммит произвёл Jesús Espino
родитель 447589a06e
Коммит 7e092886dc
5 изменённых файлов: 43 добавлений и 42 удалений

Просмотреть файл

@@ -529,32 +529,28 @@ func (us SqlUserStore) InvalidateProfilesInChannelCache(channelId string) {
}
}
func (us SqlUserStore) GetProfilesInChannel(channelId string, offset int, limit int) store.StoreChannel {
return store.Do(func(result *store.StoreResult) {
query := us.usersQuery.
Join("ChannelMembers cm ON ( cm.UserId = u.Id )").
Where("cm.ChannelId = ?", channelId).
OrderBy("u.Username ASC").
Offset(uint64(offset)).Limit(uint64(limit))
func (us SqlUserStore) GetProfilesInChannel(channelId string, offset int, limit int) ([]*model.User, *model.AppError) {
query := us.usersQuery.
Join("ChannelMembers cm ON ( cm.UserId = u.Id )").
Where("cm.ChannelId = ?", channelId).
OrderBy("u.Username ASC").
Offset(uint64(offset)).Limit(uint64(limit))
queryString, args, err := query.ToSql()
if err != nil {
result.Err = model.NewAppError("SqlUserStore.GetProfilesInChannel", "store.sql_user.app_error", nil, err.Error(), http.StatusInternalServerError)
return
}
queryString, args, err := query.ToSql()
if err != nil {
return nil, model.NewAppError("SqlUserStore.GetProfilesInChannel", "store.sql_user.app_error", nil, err.Error(), http.StatusInternalServerError)
}
var users []*model.User
if _, err := us.GetReplica().Select(&users, queryString, args...); err != nil {
result.Err = model.NewAppError("SqlUserStore.GetProfilesInChannel", "store.sql_user.get_profiles.app_error", nil, err.Error(), http.StatusInternalServerError)
return
}
var users []*model.User
if _, err := us.GetReplica().Select(&users, queryString, args...); err != nil {
return nil, model.NewAppError("SqlUserStore.GetProfilesInChannel", "store.sql_user.get_profiles.app_error", nil, err.Error(), http.StatusInternalServerError)
}
for _, u := range users {
u.Sanitize(map[string]bool{})
}
for _, u := range users {
u.Sanitize(map[string]bool{})
}
result.Data = users
})
return users, nil
}
func (us SqlUserStore) GetProfilesInChannelByStatus(channelId string, offset int, limit int) ([]*model.User, *model.AppError) {