diff --git a/app/models/profile.rb b/app/models/profile.rb index e0170c6..f77a032 100644 --- a/app/models/profile.rb +++ b/app/models/profile.rb @@ -41,7 +41,7 @@ def approve! self.update_attribute(:approved, true) end - def save_with_epic_sort(args={}) + def save_with_epic_sort(args={}) assign_attributes(args) epic_sort save @@ -50,9 +50,11 @@ def save_with_epic_sort(args={}) private def epic_sort return if organizer? - epic_length = 80 + Random.rand(20) - bio_length = blurb.present? ? blurb.length : 0 - score = (epic_length - bio_length).abs - self.sort_order = score + score = Random.rand(20) + score += 100 + Random.rand(20) if name.blank? + score += Random.rand(20) if blurb.blank? + score += Random.rand(20) if twitter.blank? + score += Random.rand(20) if homepage.blank? + self.sort_order = score end end diff --git a/app/views/kaminari/_gap.html.erb b/app/views/kaminari/_gap.html.erb index 33b9d7a..e72083d 100644 --- a/app/views/kaminari/_gap.html.erb +++ b/app/views/kaminari/_gap.html.erb @@ -5,4 +5,7 @@ per_page: number of items to fetch per page remote: data-remote -%> + \ No newline at end of file diff --git a/spec/models/profile_spec.rb b/spec/models/profile_spec.rb index 0c9cb59..e743594 100644 --- a/spec/models/profile_spec.rb +++ b/spec/models/profile_spec.rb @@ -27,14 +27,14 @@ @member.save_with_epic_sort @member.reload - @member.sort_order.should be_between(0, 20) + @member.sort_order.should be_between(0, 100) end it "should update attributes when saving with epic" do @member.save_with_epic_sort({blurb: @blurb, name: 'sample'}) @member.reload - @member.sort_order.should be_between(0, 20) + @member.sort_order.should be_between(0, 100) @member.name.should == 'sample' end @@ -52,8 +52,8 @@ @member.reload @member_2.reload - @member.sort_order.should be_between(0, 20) - @member_2.sort_order.should be_between(0, 20) + @member.sort_order.should be_between(0, 100) + @member_2.sort_order.should be_between(0, 100) end it "should not show non-organizers more than once" do