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 :site
many_to_one :follow many_to_one :follow
many_to_one :tip many_to_one :tip
one_to_one :tag one_to_one :tag
many_to_one :site_change many_to_one :site_change
many_to_one :profile_comment many_to_one :profile_comment
@ -16,6 +16,14 @@ class Event < Sequel::Model
GLOBAL_VIEWS_MINIMUM = 5 GLOBAL_VIEWS_MINIMUM = 5
GLOBAL_VIEWS_SITE_CHANGE_MINIMUM = 3_000 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 def self.news_feed_default_dataset
if SimpleCache.expired?(:excluded_actioning_site_ids) 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]} 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) exclude(is_banned: true)
unless excluded_actioning_site_ids.empty? 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 end
ds ds

View file

@ -140,10 +140,10 @@
<%== erb :'_news_actions', layout: false, locals: {event: event} %> <%== erb :'_news_actions', layout: false, locals: {event: event} %>
<% end %> <% end %>
<% if event.comments_dataset.count > 0 %> <% if event.undeleted_comments_count > 0 %>
<div class="content"> <div class="content">
<div class="comments"> <div class="comments">
<% event.comments.each do |comment| %> <% event.undeleted_comments.each do |comment| %>
<% comment_actioning_site = comment.actioning_site_dataset.select(:id, :title, :domain, :username, :stripe_customer_id, :plan_type).first %> <% comment_actioning_site = comment.actioning_site_dataset.select(:id, :title, :domain, :username, :stripe_customer_id, :plan_type).first %>
<% comment_event_site = comment.event.site_dataset.select(:id, :title, :domain, :username, :stripe_customer_id, :plan_type).first %> <% comment_event_site = comment.event.site_dataset.select(:id, :title, :domain, :username, :stripe_customer_id, :plan_type).first %>
<div class="comment" id="comment_<%= comment.id %>"> <div class="comment" id="comment_<%= comment.id %>">