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/org.go | |
parent | c1e92eeb72fe92cc30c80985e5e2b970f4735067 (diff) | |
download | gitea-fa3abc22c06843bb27089e8c0f7aebf0f5d83fcc.tar.gz gitea-fa3abc22c06843bb27089e8c0f7aebf0f5d83fcc.zip |
Added sorting to organizations, repos & users page (#222)
Diffstat (limited to 'models/org.go')
-rw-r--r-- | models/org.go | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/models/org.go b/models/org.go index 9908386f0d..b302288ca5 100644 --- a/models/org.go +++ b/models/org.go @@ -195,12 +195,19 @@ func CountOrganizations() int64 { } // Organizations returns number of organizations in given page. -func Organizations(page, pageSize int) ([]*User, error) { - orgs := make([]*User, 0, pageSize) - return orgs, x. - Limit(pageSize, (page-1)*pageSize). - Where("type=1"). - Asc("name"). +func Organizations(opts *SearchUserOptions) ([]*User, error) { + orgs := make([]*User, 0, opts.PageSize) + + if len(opts.OrderBy) == 0 { + opts.OrderBy = "name ASC" + } + + sess := x. + Limit(opts.PageSize, (opts.Page-1)*opts.PageSize). + Where("type=1") + + return orgs, sess. + OrderBy(opts.OrderBy). Find(&orgs) } |