fix deleted comments not being hidden

This commit is contained in:
Kyle Drake 2017-07-12 09:16:40 -07:00
parent de669d86cb
commit bd45dfdab6
2 changed files with 12 additions and 4 deletions

View file

@ -3,7 +3,7 @@ class Event < Sequel::Model
many_to_one :site
many_to_one :follow
many_to_one :tip
many_to_one :tip
one_to_one :tag
many_to_one :site_change
many_to_one :profile_comment
@ -16,6 +16,14 @@ class Event < Sequel::Model
GLOBAL_VIEWS_MINIMUM = 5
GLOBAL_VIEWS_SITE_CHANGE_MINIMUM = 3_000
def undeleted_comments_count
comments_dataset.exclude(is_deleted: true).count
end
def undeleted_comments
comments_dataset.exclude(is_deleted: true).order(:created_at).all
end
def self.news_feed_default_dataset
if SimpleCache.expired?(:excluded_actioning_site_ids)
res = DB[%{select distinct(actioning_site_id) from events join sites on actioning_site_id=sites.id where sites.is_banned='t' or sites.is_nsfw='t' or sites.is_deleted='t'}].all.collect {|r| r[:actioning_site_id]}
@ -32,7 +40,7 @@ class Event < Sequel::Model
exclude(is_banned: true)
unless excluded_actioning_site_ids.empty?
ds.where!("actioning_site_id is null or actioning_site_id not in ?", excluded_actioning_site_ids)
return ds.where("actioning_site_id is null or actioning_site_id not in ?", excluded_actioning_site_ids)
end
ds