mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: add support for tag group search
The behaviour of #TERM in search has been amended 1. We try category or subcategory slugs 2. We try tags 3. We try tag-groups The term `hello #my-group` will search for all posts tagged with any of the tags in the tag group `My Group` Future work may be introducing a slug cache here or caching it in the table but the assumption is that the number of tag groups will not be huge
This commit is contained in:
@@ -36,11 +36,18 @@ class TagGroup < ActiveRecord::Base
|
||||
@permissions = TagGroup.resolve_permissions(permissions)
|
||||
end
|
||||
|
||||
def self.resolve_permissions(permissions)
|
||||
everyone_group_id = Group::AUTO_GROUPS[:everyone]
|
||||
full = TagGroupPermission.permission_types[:full]
|
||||
# TODO: long term we can cache this if TONs of tag groups exist
|
||||
def self.find_id_by_slug(slug)
|
||||
self.pluck(:id, :name).each do |id, name|
|
||||
if Slug.for(name) == slug
|
||||
return id
|
||||
end
|
||||
end
|
||||
nil
|
||||
end
|
||||
|
||||
mapped = permissions.map do |group, permission|
|
||||
def self.resolve_permissions(permissions)
|
||||
permissions.map do |group, permission|
|
||||
group_id = Group.group_id_from_param(group)
|
||||
permission = TagGroupPermission.permission_types[permission] unless permission.is_a?(Integer)
|
||||
[group_id, permission]
|
||||
|
Reference in New Issue
Block a user