hide saved search functionality if not enabled
This commit is contained in:
@@ -23,11 +23,12 @@ module Moderator
|
||||
tags = Tag.scan_tags(antecedent, :strip_metatags => true)
|
||||
conds = tags.map {|x| "tag_query like ?"}.join(" AND ")
|
||||
conds = [conds, *tags.map {|x| "%#{x}%"}]
|
||||
SavedSearch.where(*conds).find_each do |ss|
|
||||
ss.tag_query = (ss.tag_query_array - tags + antecedent).uniq.join(" ")
|
||||
ss.save
|
||||
if SavedSearch.enabled?
|
||||
SavedSearch.where(*conds).find_each do |ss|
|
||||
ss.tag_query = (ss.tag_query_array - tags + antecedent).uniq.join(" ")
|
||||
ss.save
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -102,15 +102,17 @@ class PostQueryBuilder
|
||||
end
|
||||
|
||||
def add_saved_search_relation(saved_searches, relation)
|
||||
saved_searches.each do |saved_search|
|
||||
if saved_search == "all"
|
||||
post_ids = SavedSearch.post_ids(CurrentUser.id)
|
||||
else
|
||||
post_ids = SavedSearch.post_ids(CurrentUser.id, saved_search)
|
||||
end
|
||||
if SavedSearch.enabled?
|
||||
saved_searches.each do |saved_search|
|
||||
if saved_search == "all"
|
||||
post_ids = SavedSearch.post_ids(CurrentUser.id)
|
||||
else
|
||||
post_ids = SavedSearch.post_ids(CurrentUser.id, saved_search)
|
||||
end
|
||||
|
||||
post_ids = [0] if post_ids.empty?
|
||||
relation = relation.where(["posts.id IN (?)", post_ids])
|
||||
post_ids = [0] if post_ids.empty?
|
||||
relation = relation.where(["posts.id IN (?)", post_ids])
|
||||
end
|
||||
end
|
||||
|
||||
relation
|
||||
|
||||
Reference in New Issue
Block a user