diff options
author | Odin Ugedal <odin@ugedal.com> | 2016-03-15 14:16:58 +0100 |
---|---|---|
committer | Odin Ugedal <odin@ugedal.com> | 2016-03-15 14:16:58 +0100 |
commit | 3253e3c5aaf19f8cb8dda20b2a01aafe36d28066 (patch) | |
tree | e43ef37eff8ccbf0c51af877cea22a731c141e12 | |
parent | 9df5c39bca6fb397449525b0f1eb0d24d993439f (diff) | |
download | gitea-3253e3c5aaf19f8cb8dda20b2a01aafe36d28066.tar.gz gitea-3253e3c5aaf19f8cb8dda20b2a01aafe36d28066.zip |
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.
-rw-r--r-- | models/user.go | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/models/user.go b/models/user.go index 82f927891c..93db70a414 100644 --- a/models/user.go +++ b/models/user.go @@ -1137,9 +1137,13 @@ func SearchUserByName(opts *SearchUserOptions) (users []*User, _ int64, _ error) opts.Page = 1 } + searchQuery := "%" + opts.Keyword + "%" users = make([]*User, 0, opts.PageSize) // 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 countSess = *sess |