Extend user list to allow searching by name or email

This commit is contained in:
Tom Hughes 2025-02-22 11:40:58 +00:00
parent d82a3df97a
commit 837924027a
4 changed files with 47 additions and 4 deletions

View file

@ -13,10 +13,11 @@ module Users
##
# display a list of users matching specified criteria
def show
@params = params.permit(:status, :ip, :before, :after)
@params = params.permit(:status, :username, :ip, :before, :after)
users = User.all
users = users.where(:status => @params[:status]) if @params[:status].present?
users = users.where("LOWER(email) = LOWER(?) OR LOWER(NORMALIZE(display_name, NFKC)) = LOWER(NORMALIZE(?, NFKC))", @params[:username], @params[:username]) if @params[:username].present?
users = users.where("creation_address <<= ?", @params[:ip]) if @params[:ip].present?
@users_count = users.limit(501).count