Commit 0f4a925e67b3c854d7cd0c1d13ccceae52633960

Authored by Victor Costa
1 parent a20452cd

rails3: fix people_block plugin

Showing 1 changed file with 4 additions and 4 deletions   Show diff stats
plugins/people_block/lib/people_block_base.rb
@@ -29,11 +29,11 @@ class PeopleBlockBase < Block @@ -29,11 +29,11 @@ class PeopleBlockBase < Block
29 result = nil 29 result = nil
30 visible_profiles = profiles.visible.includes([:image,:domains,:preferred_domain,:environment]) 30 visible_profiles = profiles.visible.includes([:image,:domains,:preferred_domain,:environment])
31 if !prioritize_profiles_with_image 31 if !prioritize_profiles_with_image
32 - result = visible_profiles.all(:limit => limit, :order => 'updated_at DESC').sort_by{ rand }  
33 - elsif visible_profiles.with_image.count >= limit  
34 - result = visible_profiles.with_image.all(:limit => limit * 5, :order => 'updated_at DESC').sort_by{ rand } 32 + result = visible_profiles.all(:limit => limit, :order => 'profiles.updated_at DESC').sort_by{ rand }
  33 + elsif profiles.visible.with_image.count >= limit
  34 + result = visible_profiles.with_image.all(:limit => limit * 5, :order => 'profiles.updated_at DESC').sort_by{ rand }
35 else 35 else
36 - result = visible_profiles.with_image.sort_by{ rand } + visible_profiles.without_image.all(:limit => limit * 5, :order => 'updated_at DESC').sort_by{ rand } 36 + result = visible_profiles.with_image.sort_by{ rand } + visible_profiles.without_image.all(:limit => limit * 5, :order => 'profiles.updated_at DESC').sort_by{ rand }
37 end 37 end
38 result.slice(0..limit-1) 38 result.slice(0..limit-1)
39 end 39 end