diff options
author | Bwko <bouwko@gmail.com> | 2016-12-24 15:42:26 +0100 |
---|---|---|
committer | Lunny Xiao <xiaolunwen@gmail.com> | 2016-12-24 22:42:26 +0800 |
commit | fa3abc22c06843bb27089e8c0f7aebf0f5d83fcc (patch) | |
tree | f7763df24980f419698ea75f4cd2d080784a62d2 /models/user.go | |
parent | c1e92eeb72fe92cc30c80985e5e2b970f4735067 (diff) | |
download | gitea-fa3abc22c06843bb27089e8c0f7aebf0f5d83fcc.tar.gz gitea-fa3abc22c06843bb27089e8c0f7aebf0f5d83fcc.zip |
Added sorting to organizations, repos & users page (#222)
Diffstat (limited to 'models/user.go')
-rw-r--r-- | models/user.go | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/models/user.go b/models/user.go index 1b645a5285..803cb3b03e 100644 --- a/models/user.go +++ b/models/user.go @@ -641,12 +641,18 @@ func CountUsers() int64 { } // Users returns number of users in given page. -func Users(page, pageSize int) ([]*User, error) { - users := make([]*User, 0, pageSize) - return users, x. - Limit(pageSize, (page-1)*pageSize). - Where("type=0"). - Asc("name"). +func Users(opts *SearchUserOptions) ([]*User, error) { + if len(opts.OrderBy) == 0 { + opts.OrderBy = "name ASC" + } + + users := make([]*User, 0, opts.PageSize) + sess := x. + Limit(opts.PageSize, (opts.Page-1)*opts.PageSize). + Where("type=0") + + return users, sess. + OrderBy(opts.OrderBy). Find(&users) } |