hide saved search functionality if not enabled

This commit is contained in:
Albert Yi
2016-12-21 11:54:43 -08:00
parent ee4ebce4d7
commit 62956be384
14 changed files with 198 additions and 104 deletions

View File

@@ -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

View File

@@ -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