MM-18512 Use options struct for GetProfilesWithoutTeam and add filtering to API (#12200)

* Use options struct for GetProfilesWithoutTeam and add filtering

* Fix test
Этот коммит содержится в:
Joram Wilander
2019-09-17 15:13:17 -04:00
коммит произвёл Miguel de la Cruz
родитель 4ce7b92283
Коммит 3d4c941ba8
11 изменённых файлов: 137 добавлений и 833 удалений

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

@@ -667,7 +667,8 @@ func (us SqlUserStore) GetProfilesNotInChannel(teamId string, channelId string,
return users, nil
}
func (us SqlUserStore) GetProfilesWithoutTeam(offset int, limit int, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, *model.AppError) {
func (us SqlUserStore) GetProfilesWithoutTeam(options *model.UserGetOptions) ([]*model.User, *model.AppError) {
isPostgreSQL := us.DriverName() == model.DATABASE_DRIVER_POSTGRES
query := us.usersQuery.
Where(`(
SELECT
@@ -679,9 +680,15 @@ func (us SqlUserStore) GetProfilesWithoutTeam(offset int, limit int, viewRestric
AND TeamMembers.DeleteAt = 0
) = 0`).
OrderBy("u.Username ASC").
Offset(uint64(offset)).Limit(uint64(limit))
Offset(uint64(options.Page * options.PerPage)).Limit(uint64(options.PerPage))
query = applyViewRestrictionsFilter(query, viewRestrictions, true)
query = applyViewRestrictionsFilter(query, options.ViewRestrictions, true)
query = applyRoleFilter(query, options.Role, isPostgreSQL)
if options.Inactive {
query = query.Where("u.DeleteAt != 0")
}
queryString, args, err := query.ToSql()
if err != nil {