2
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2025-09-06 10:50:21 +08:00

FIX: Better match when searching for groups.

This commit is contained in:
Guo Xiang Tan 2017-11-02 10:20:14 +08:00
parent ab2a5cef38
commit edf4af608e
3 changed files with 25 additions and 23 deletions

View file

@ -369,10 +369,14 @@ class Group < ActiveRecord::Base
lookup_group(name) || refresh_automatic_group!(name)
end
def self.search_group(name)
Group.where(visibility_level: visibility_levels[:public]).where(
"name ILIKE :term_like OR full_name ILIKE :term_like", term_like: "#{name}%"
)
def self.search_groups(name, groups: nil)
query = groups || Group
query
.where(visibility_level: visibility_levels[:public])
.where(
"name ILIKE :term_like OR full_name ILIKE :term_like", term_like: "%#{name}%"
)
end
def self.lookup_group(name)