Merge branch 'master' into fix-3278

This commit is contained in:
Albert Yi
2017-12-13 14:30:08 -08:00
committed by GitHub
27 changed files with 312 additions and 79 deletions

View File

@@ -18,11 +18,12 @@ module Moderator
post.update_attributes(:tag_string => tags)
end
tags = Tag.scan_tags(antecedent, :strip_metatags => true)
conds = tags.map {|x| "query like ?"}.join(" AND ")
conds = [conds, *tags.map {|x| "%#{x.to_escaped_for_sql_like}%"}]
if SavedSearch.enabled?
SavedSearch.where(*conds).find_each do |ss|
tags = Tag.scan_tags(antecedent, :strip_metatags => true)
# https://www.postgresql.org/docs/current/static/functions-array.html
saved_searches = SavedSearch.where("string_to_array(query, ' ') @> ARRAY[?]", tags)
saved_searches.find_each do |ss|
ss.query = (ss.query.split - tags + [consequent]).uniq.join(" ")
ss.save
end

View File

@@ -87,11 +87,15 @@ module PostSets
end
def banned_posts
posts.select(&:is_banned?)
posts.select { |p| p.banblocked? }
end
def censored_posts
hidden_posts - banned_posts
posts.select { |p| p.levelblocked? && !p.banblocked? }
end
def safe_posts
posts.select { |p| p.safeblocked? && !p.levelblocked? && !p.banblocked? }
end
def use_sequential_paginator?