Added sorting to organizations, repos & users page (#222)
This commit is contained in:
parent
c1e92eeb72
commit
fa3abc22c0
9 changed files with 177 additions and 49 deletions
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue