diff --git a/models/site.rb b/models/site.rb index 886b43ed..5c9df0f9 100644 --- a/models/site.rb +++ b/models/site.rb @@ -166,6 +166,7 @@ class Site < Sequel::Model MAX_COMMENTS_PER_DAY = 5 SANDBOX_TIME = 14.days BLACK_BOX_WAIT_TIME = 10.seconds + MAX_DISPLAY_FOLLOWS = 56*3 many_to_many :tags @@ -568,8 +569,8 @@ class Site < Sequel::Model follows_dataset.all end - def profile_follows_actioning_ids - follows_dataset.select(:actioning_site_id).exclude(:sites__site_changed => false).all + def profile_follows_actioning_ids(limit=nil) + follows_dataset.select(:actioning_site_id).exclude(:sites__site_changed => false).limit(limit).all end =begin diff --git a/views/_follows.erb b/views/_follows.erb index d9e1a6aa..851257e7 100644 --- a/views/_follows.erb +++ b/views/_follows.erb @@ -1,8 +1,8 @@ -<% site_followings = site.followings %> -<% if (!is_current_site && !site_followings.empty?) || is_current_site %> +<% site_followings = site.followings_dataset.count %> +<% if (!is_current_site && site_followings > 0) || is_current_site %>

<%= is_current_site ? 'Sites you follow' : 'This site follows' %>

- <% if site_followings.empty? %> + <% if site_followings == 0 %>

You are not following any sites yet. Add some by browsing sites or looking at your tags. <% else %> <% site.followings_dataset.select(:site_id).all.each do |following| %> @@ -12,17 +12,22 @@

<% end %> -<% site_follows = site.follows %> -<% if (!is_current_site && !site_follows.empty?) || is_current_site %> +<% site_follows = site.follows_dataset.count %> +<% if (!is_current_site && site_follows > 0) || is_current_site %>

Followers

- <% if site_follows.empty? %> + <% if site_follows == 0 %> No followers yet. <% else %> - <% site.profile_follows_actioning_ids.each do |follow| %> + <% site_profile_follows_actioning_ids = site.profile_follows_actioning_ids %> + <% site_profile_follows_actioning_ids[0...Site::MAX_DISPLAY_FOLLOWS].each do |follow| %> <% follow_actioning_site = follow.actioning_site_dataset.select(:username).first %> <% end %> + + <% if Site::MAX_DISPLAY_FOLLOWS < site_profile_follows_actioning_ids.count %> + see more + <% end %> <% end %>
<% end %>