Admins can now do unlimited page size user search (listAllUsers & listAllOrgs) (#6143)
Non-admins will default to 10 page size
This commit is contained in:
parent
477ef46251
commit
994b1be9d1
|
@ -1433,6 +1433,9 @@ func SearchUsers(opts *SearchUserOptions) (users []*User, _ int64, _ error) {
|
||||||
if opts.PageSize > 0 {
|
if opts.PageSize > 0 {
|
||||||
sess = sess.Limit(opts.PageSize, (opts.Page-1)*opts.PageSize)
|
sess = sess.Limit(opts.PageSize, (opts.Page-1)*opts.PageSize)
|
||||||
}
|
}
|
||||||
|
if opts.PageSize == -1 {
|
||||||
|
opts.PageSize = int(count)
|
||||||
|
}
|
||||||
|
|
||||||
users = make([]*User, 0, opts.PageSize)
|
users = make([]*User, 0, opts.PageSize)
|
||||||
return users, count, sess.OrderBy(opts.OrderBy.String()).Find(&users)
|
return users, count, sess.OrderBy(opts.OrderBy.String()).Find(&users)
|
||||||
|
|
|
@ -55,7 +55,7 @@ func Search(ctx *context.APIContext) {
|
||||||
Type: models.UserTypeIndividual,
|
Type: models.UserTypeIndividual,
|
||||||
PageSize: com.StrTo(ctx.Query("limit")).MustInt(),
|
PageSize: com.StrTo(ctx.Query("limit")).MustInt(),
|
||||||
}
|
}
|
||||||
if opts.PageSize == 0 {
|
if opts.PageSize <= 0 {
|
||||||
opts.PageSize = 10
|
opts.PageSize = 10
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue