Migrate "User.GetProfilesWithoutTeam" to Sync by default (#11612)
* 👤 Migrates GetProfilesWithoutTeam to Sync * 🔬 Fix tests * 🗣 Address CR feedback * 🏃♂️ Run `make store-mocks`
Этот коммит содержится в:
коммит произвёл
Jesús Espino
родитель
48e06e9bc4
Коммит
53f1cf1cb2
@@ -673,41 +673,37 @@ func (us SqlUserStore) GetProfilesNotInChannel(teamId string, channelId string,
|
||||
return users, nil
|
||||
}
|
||||
|
||||
func (us SqlUserStore) GetProfilesWithoutTeam(offset int, limit int, viewRestrictions *model.ViewUsersRestrictions) store.StoreChannel {
|
||||
return store.Do(func(result *store.StoreResult) {
|
||||
query := us.usersQuery.
|
||||
Where(`(
|
||||
SELECT
|
||||
COUNT(0)
|
||||
FROM
|
||||
TeamMembers
|
||||
WHERE
|
||||
TeamMembers.UserId = u.Id
|
||||
AND TeamMembers.DeleteAt = 0
|
||||
) = 0`).
|
||||
OrderBy("u.Username ASC").
|
||||
Offset(uint64(offset)).Limit(uint64(limit))
|
||||
func (us SqlUserStore) GetProfilesWithoutTeam(offset int, limit int, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, *model.AppError) {
|
||||
query := us.usersQuery.
|
||||
Where(`(
|
||||
SELECT
|
||||
COUNT(0)
|
||||
FROM
|
||||
TeamMembers
|
||||
WHERE
|
||||
TeamMembers.UserId = u.Id
|
||||
AND TeamMembers.DeleteAt = 0
|
||||
) = 0`).
|
||||
OrderBy("u.Username ASC").
|
||||
Offset(uint64(offset)).Limit(uint64(limit))
|
||||
|
||||
query = applyViewRestrictionsFilter(query, viewRestrictions, true)
|
||||
query = applyViewRestrictionsFilter(query, viewRestrictions, true)
|
||||
|
||||
queryString, args, err := query.ToSql()
|
||||
if err != nil {
|
||||
result.Err = model.NewAppError("SqlUserStore.GetProfilesWithoutTeam", "store.sql_user.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
queryString, args, err := query.ToSql()
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("SqlUserStore.GetProfilesWithoutTeam", "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.GetProfilesWithoutTeam", "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.GetProfilesWithoutTeam", "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) GetProfilesByUsernames(usernames []string, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, *model.AppError) {
|
||||
|
||||
Ссылка в новой задаче
Block a user