From 0f4a925e67b3c854d7cd0c1d13ccceae52633960 Mon Sep 17 00:00:00 2001 From: Victor Costa Date: Fri, 27 Jun 2014 10:15:17 -0300 Subject: [PATCH] rails3: fix people_block plugin --- plugins/people_block/lib/people_block_base.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/people_block/lib/people_block_base.rb b/plugins/people_block/lib/people_block_base.rb index 114ae8a..6d6fa08 100644 --- a/plugins/people_block/lib/people_block_base.rb +++ b/plugins/people_block/lib/people_block_base.rb @@ -29,11 +29,11 @@ class PeopleBlockBase < Block result = nil visible_profiles = profiles.visible.includes([:image,:domains,:preferred_domain,:environment]) if !prioritize_profiles_with_image - result = visible_profiles.all(:limit => limit, :order => 'updated_at DESC').sort_by{ rand } - elsif visible_profiles.with_image.count >= limit - result = visible_profiles.with_image.all(:limit => limit * 5, :order => 'updated_at DESC').sort_by{ rand } + result = visible_profiles.all(:limit => limit, :order => 'profiles.updated_at DESC').sort_by{ rand } + elsif profiles.visible.with_image.count >= limit + result = visible_profiles.with_image.all(:limit => limit * 5, :order => 'profiles.updated_at DESC').sort_by{ rand } else - result = visible_profiles.with_image.sort_by{ rand } + visible_profiles.without_image.all(:limit => limit * 5, :order => 'updated_at DESC').sort_by{ rand } + result = visible_profiles.with_image.sort_by{ rand } + visible_profiles.without_image.all(:limit => limit * 5, :order => 'profiles.updated_at DESC').sort_by{ rand } end result.slice(0..limit-1) end -- libgit2 0.21.2