Don't show/count follows/followers for banned/deleted/disabled profile sites

This commit is contained in:
Kyle Drake 2020-02-28 21:55:43 -05:00
parent 38f55a8ec0
commit 1073ed8c2a
4 changed files with 12 additions and 8 deletions

View file

@ -533,14 +533,18 @@ class Site < Sequel::Model
}
end
# Who this site follows
# Who this site is following
def followings_dataset
super.select_all(:follows).inner_join(:sites, :id=>:site_id).exclude(:sites__is_deleted => true).exclude(:sites__is_banned => true)
super.select_all(:follows).inner_join(:sites, :id=>:site_id).exclude(:sites__is_deleted => true).exclude(:sites__is_banned => true).exclude(:sites__profile_enabled => false).order(:score.desc)
end
# Who this site is following
# Who this site follows
def follows_dataset
super.select_all(:follows).inner_join(:sites, :id=>:actioning_site_id).exclude(:sites__is_deleted => true).order(:score.desc)
super.select_all(:follows).inner_join(:sites, :id=>:actioning_site_id).exclude(:sites__is_deleted => true).exclude(:sites__is_banned => true).exclude(:sites__profile_enabled => false).order(:score.desc)
end
def followings
followings_dataset.all
end
def follows

View file

@ -71,7 +71,7 @@
</a>
</div>
<div class="site-tags">
<% if suggested_site.tags.count > 0 %>
<% if suggested_site.tags_dataset.count > 0 %>
<i class="fa fa-tag"></i>
<% suggested_site.tags.each_with_index do |tag, index| %>
<a class="" href="/browse?tag=<%= Rack::Utils.escape tag.name %>"><%= tag.name %></a><% if index != suggested_site.tags.length - 1 %>,<% end %>
@ -98,7 +98,7 @@
<% end %>
</div>
<div class="col col-50">
<% follow_count = site.follows.count %>
<% follow_count = site.follows_dataset.count %>
<div><strong><%= site.views.format_large_number %></strong> views</div>
<div><strong><%= follow_count.format_large_number %></strong> follower<%= follow_count == 1 ? '' : 's' %></div>
</div>

View file

@ -24,7 +24,7 @@
<p><a href="<%= site.latest_archive.url %>" style="margin-right: 5px"><%= site.latest_archive.ipfs_hash %></a><small style="font-size: 7pt"><a href="/permanent-web">(what is this?)</a></small></p>
<% end %>
-->
<% follow_count = site.follows.count %>
<% follow_count = site.follows_dataset.count %>
<div class="stats">
<div class="stat"><strong><%= site.views.format_large_number %></strong> <span>view<%= site.views == 1 ? '' : 's' %></span></div>
<div class="stat"><strong><%= follow_count.format_large_number %></strong> <span>follower<%= follow_count == 1 ? '' : 's' %></span></div>

View file

@ -258,7 +258,7 @@
<% end %>
</div>
<div class="col col-50">
<% follow_count = site.follows.count %>
<% follow_count = site.follows_dataset.count %>
<div><strong><%= site.views.format_large_number %></strong> views</div>
<div><strong><%= follow_count.format_large_number %></strong> follower<%= follow_count == 1 ? '' : 's' %></div>
</div>