diff options
author | Shashvat Kedia <sk261@snu.edu.in> | 2019-01-24 04:00:19 +0530 |
---|---|---|
committer | techknowlogick <matti@mdranta.net> | 2019-01-23 17:30:19 -0500 |
commit | 1b90692844c1b714d9c03cf7c96e7f62923236c0 (patch) | |
tree | cb9bb22743da0898bb39c718bb3537a9581e8ea5 /models/user.go | |
parent | b9f87376a2de9dd56fb6c374fc786b6aebd1e911 (diff) | |
download | gitea-1b90692844c1b714d9c03cf7c96e7f62923236c0.tar.gz gitea-1b90692844c1b714d9c03cf7c96e7f62923236c0.zip |
New API routes added (#5594)
* New API routes added
* Comments added
* Build fix
* swagger_v1_json.tmpl without new line character
* Typo fix
* Code review changes
* Code review changes
* Add copyright
* Add copyright
* Add copyright
* Update per @lafriks feedback
* Update org.go
* Update user.go
* Update user.go
* make fmt
Diffstat (limited to 'models/user.go')
-rw-r--r-- | models/user.go | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/models/user.go b/models/user.go index 764c2280d7..0d8f608861 100644 --- a/models/user.go +++ b/models/user.go @@ -1,4 +1,5 @@ // Copyright 2014 The Gogs Authors. All rights reserved. +// Copyright 2019 The Gitea Authors. All rights reserved. // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. @@ -1358,7 +1359,7 @@ func SearchUsers(opts *SearchUserOptions) (users []*User, _ int64, _ error) { return nil, 0, fmt.Errorf("Count: %v", err) } - if opts.PageSize <= 0 || opts.PageSize > setting.UI.ExplorePagingNum { + if opts.PageSize == 0 || opts.PageSize > setting.UI.ExplorePagingNum { opts.PageSize = setting.UI.ExplorePagingNum } if opts.Page <= 0 { @@ -1368,11 +1369,13 @@ func SearchUsers(opts *SearchUserOptions) (users []*User, _ int64, _ error) { opts.OrderBy = SearchOrderByAlphabetically } + sess := x.Where(cond) + if opts.PageSize > 0 { + sess = sess.Limit(opts.PageSize, (opts.Page-1)*opts.PageSize) + } + users = make([]*User, 0, opts.PageSize) - return users, count, x.Where(cond). - Limit(opts.PageSize, (opts.Page-1)*opts.PageSize). - OrderBy(opts.OrderBy.String()). - Find(&users) + return users, count, sess.OrderBy(opts.OrderBy.String()).Find(&users) } // GetStarredRepos returns the repos starred by a particular user |