mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-26 18:00:34 +00:00
Make user search look in username, name and email
Make user search function look in username (lower_name), full name (full_name) and primary email (email). This will benefit searching after user in "explore", admin panel and when adding new collaborators.
This commit is contained in:
parent
9df5c39bca
commit
3253e3c5aa
1 changed files with 5 additions and 1 deletions
|
@ -1137,9 +1137,13 @@ func SearchUserByName(opts *SearchUserOptions) (users []*User, _ int64, _ error)
|
||||||
opts.Page = 1
|
opts.Page = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
searchQuery := "%" + opts.Keyword + "%"
|
||||||
users = make([]*User, 0, opts.PageSize)
|
users = make([]*User, 0, opts.PageSize)
|
||||||
// Append conditions
|
// Append conditions
|
||||||
sess := x.Where("lower_name like ?", "%"+opts.Keyword+"%").And("type = ?", opts.Type)
|
sess := x.Where("lower_name like ?", searchQuery).
|
||||||
|
Or("full_name like ?", searchQuery).
|
||||||
|
Or("email like ?", searchQuery).
|
||||||
|
And("type = ?", opts.Type)
|
||||||
|
|
||||||
var countSess xorm.Session
|
var countSess xorm.Session
|
||||||
countSess = *sess
|
countSess = *sess
|
||||||
|
|
Loading…
Reference in a new issue