mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-09 03:11:51 +01:00
#13 fix postgres aggregate
This commit is contained in:
parent
73e98c91c3
commit
263304b6b7
2 changed files with 6 additions and 7 deletions
|
@ -1527,9 +1527,6 @@ func SearchRepositoryByName(opts *SearchRepoOptions) (repos []*Repository, _ int
|
|||
if !opts.Private {
|
||||
sess.And("is_private=?", false)
|
||||
}
|
||||
if len(opts.OrderBy) > 0 {
|
||||
sess.OrderBy(opts.OrderBy)
|
||||
}
|
||||
|
||||
var countSess xorm.Session
|
||||
countSess = *sess
|
||||
|
@ -1538,6 +1535,9 @@ func SearchRepositoryByName(opts *SearchRepoOptions) (repos []*Repository, _ int
|
|||
return nil, 0, fmt.Errorf("Count: %v", err)
|
||||
}
|
||||
|
||||
if len(opts.OrderBy) > 0 {
|
||||
sess.OrderBy(opts.OrderBy)
|
||||
}
|
||||
return repos, count, sess.Limit(opts.PageSize, (opts.Page-1)*opts.PageSize).Find(&repos)
|
||||
}
|
||||
|
||||
|
|
|
@ -1139,11 +1139,7 @@ func SearchUserByName(opts *SearchUserOptions) (users []*User, _ int64, _ error)
|
|||
|
||||
users = make([]*User, 0, opts.PageSize)
|
||||
// Append conditions
|
||||
fmt.Println(opts.Type)
|
||||
sess := x.Where("lower_name like ?", "%"+opts.Keyword+"%").And("type = ?", opts.Type)
|
||||
if len(opts.OrderBy) > 0 {
|
||||
sess.OrderBy(opts.OrderBy)
|
||||
}
|
||||
|
||||
var countSess xorm.Session
|
||||
countSess = *sess
|
||||
|
@ -1152,6 +1148,9 @@ func SearchUserByName(opts *SearchUserOptions) (users []*User, _ int64, _ error)
|
|||
return nil, 0, fmt.Errorf("Count: %v", err)
|
||||
}
|
||||
|
||||
if len(opts.OrderBy) > 0 {
|
||||
sess.OrderBy(opts.OrderBy)
|
||||
}
|
||||
return users, count, sess.Limit(opts.PageSize, (opts.Page-1)*opts.PageSize).Find(&users)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue