FIX add nickname lastname query conditions for list users api

This commit is contained in:
jasder 2021-05-17 16:57:46 +08:00
parent acc4282c8e
commit 2f9d583fac
1 changed files with 2 additions and 1 deletions

View File

@ -168,7 +168,8 @@ class User < Owner
# Groups and active users
scope :active, lambda { where(status: STATUS_ACTIVE) }
scope :like, lambda { |keywords|
where("LOWER(concat(lastname, firstname, login, mail)) LIKE ?", "%#{keywords.split(" ").join('|')}%") unless keywords.blank?
sql = "CONCAT(lastname, firstname) LIKE :keyword OR login LIKE :keyword OR mail LIKE :keyword OR nickname LIKE :keyword"
where(sql, :search => "%#{keywords.split(" ").join('|')}%") unless keywords.blank?
}
scope :simple_select, -> {select(:id, :login, :lastname,:firstname, :nickname, :gitea_uid, :type)}