aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2016-03-15 19:39:12 -0400
committerUnknwon <u@gogs.io>2016-03-15 19:39:12 -0400
commit94d7b62922055d74424fa20439b563b0457b3558 (patch)
treebb833032dc38b02a00dc154b6e5327576ac2a1a9
parent2df42e369ea8c4441c814e472d3b5dbaa59ff11a (diff)
parent6ccb2d36cfbe030cb1a72263d6889e79d738df3f (diff)
downloadgitea-94d7b62922055d74424fa20439b563b0457b3558.tar.gz
gitea-94d7b62922055d74424fa20439b563b0457b3558.zip
Merge pull request #2831 from odinuge/user-search-name
Make user search look in username, name and email
-rw-r--r--models/user.go5
1 files changed, 4 insertions, 1 deletions
diff --git a/models/user.go b/models/user.go
index 82f927891c..a1d1f3b211 100644
--- a/models/user.go
+++ b/models/user.go
@@ -1137,9 +1137,12 @@ 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).
+ And("type = ?", opts.Type)
var countSess xorm.Session
countSess = *sess