mirror of
				https://codeberg.org/forgejo/forgejo.git
				synced 2025-11-04 08:21:11 +00:00 
			
		
		
		
	Merge pull request #2831 from odinuge/user-search-name
Make user search look in username, name and email
This commit is contained in:
		
				commit
				
					
						94d7b62922
					
				
			
		
					 1 changed files with 4 additions and 1 deletions
				
			
		| 
						 | 
					@ -1137,9 +1137,12 @@ 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).
 | 
				
			||||||
 | 
							And("type = ?", opts.Type)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	var countSess xorm.Session
 | 
						var countSess xorm.Session
 | 
				
			||||||
	countSess = *sess
 | 
						countSess = *sess
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue