forked from Gitlink/forgeplus
fixed 搜索用户时过虑表情字符
This commit is contained in:
parent
e9a152032c
commit
6e16a9397c
|
@ -69,6 +69,8 @@ class Owner < ApplicationRecord
|
|||
has_many :applied_transfer_projects, dependent: :destroy
|
||||
|
||||
scope :like, lambda { |keywords|
|
||||
# 表情处理
|
||||
keywords = keywords.each_char.select { |c| c.bytes.first < 240 }.join('')
|
||||
sql = "CONCAT(lastname, firstname) LIKE :search OR nickname LIKE :search OR login LIKE :search "
|
||||
where(sql, :search => "%#{keywords.strip}%") unless keywords.blank?
|
||||
}
|
||||
|
|
|
@ -185,6 +185,8 @@ class User < Owner
|
|||
# Groups and active users
|
||||
scope :active, lambda { where(status: [STATUS_ACTIVE, STATUS_EDIT_INFO]) }
|
||||
scope :like, lambda { |keywords|
|
||||
# 表情处理
|
||||
keywords = keywords.each_char.select { |c| c.bytes.first < 240 }.join('')
|
||||
sql = "CONCAT(lastname, firstname) LIKE :search OR nickname LIKE :search OR login LIKE :search OR mail LIKE :search OR nickname LIKE :search"
|
||||
where(sql, :search => "%#{keywords.strip}%") unless keywords.blank?
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue