Skip to content
This repository has been archived by the owner on Jan 30, 2019. It is now read-only.

Commit

Permalink
Change epic_sort algorithm.
Browse files Browse the repository at this point in the history
This method should penalize people a ton if they don't have names and a
little for each other profile piece they're missing.

Part of issue #51.
  • Loading branch information
ckrailo committed Jul 16, 2014
1 parent 8262f94 commit 4740587
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions app/models/profile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

0 comments on commit 4740587

Please sign in to comment.