From 105ef25284e4828f1651c23eb1b8937d3e50db4d Mon Sep 17 00:00:00 2001 From: Luciano Prestes Cavalcanti Date: Wed, 2 Sep 2015 02:08:24 +0200 Subject: [PATCH] Fix for filter_communities on communities_block with another plugin --- lib/ext/communities_block.rb | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/lib/ext/communities_block.rb b/lib/ext/communities_block.rb index 25a968d..1d36e84 100644 --- a/lib/ext/communities_block.rb +++ b/lib/ext/communities_block.rb @@ -4,16 +4,9 @@ class CommunitiesBlock def profile_list result = get_visible_profiles + valid_communities_string = Community.get_valid_communities_string - list_without_institution = [] - - result.each do |profile| - if profile.class == Community && !profile.institution? - list_without_institution << profile - end - end - - result = list_without_institution + result.each{|community| @scope.delete(community) unless eval(valid_communities_string)} result.slice(0..get_limit-1) end @@ -26,24 +19,23 @@ class CommunitiesBlock def get_visible_profiles visible_profiles = profiles.visible.includes( - [:image,:domains,:preferred_domain,:environment] + [:image,:domains,:preferred_domain,:environment] ) if !prioritize_profiles_with_image return visible_profiles.all( - :limit => get_limit, - :order => 'profiles.updated_at DESC' + :limit => get_limit, + :order => 'profiles.updated_at DESC' ).sort_by {rand} elsif profiles.visible.with_image.count >= get_limit return visible_profiles.with_image.all( - :limit => get_limit * 5, - :order => 'profiles.updated_at DESC' + :limit => get_limit * 5, + :order => 'profiles.updated_at DESC' ).sort_by {rand} else return visible_profiles.with_image.sort_by {rand} + - visible_profiles.without_image.all( - :limit => get_limit * 5, :order => 'profiles.updated_at DESC' - ).sort_by {rand} + visible_profiles.without_image.all( + :limit => get_limit * 5, :order => 'profiles.updated_at DESC' + ).sort_by {rand} end end - end -- libgit2 0.21.2