Permalink
Browse files

better next team picking algorithm

  • Loading branch information...
1 parent d131fea commit f49dfbe0e173eae3606d50fa5ba6d77037ff73ff @gerad gerad committed Nov 13, 2012
Showing with 18 additions and 5 deletions.
  1. +18 −5 models/person.coffee
View
23 models/person.coffee
@@ -193,9 +193,6 @@ PersonSchema.method 'nextTeam', (next) ->
# non-technical judges don't see technical entries
filter.technical = ($ne: true) if not @technical
- # judges focus on good stuff
- #filter['scores.overall'] = ($gt: 15)
-
# judges only see entries with pitch videos
filter['entry.videoURL'] = /./
@@ -205,12 +202,28 @@ PersonSchema.method 'nextTeam', (next) ->
sort.push ['updatedAt', -1]
Team = mongoose.model 'Team'
+ Vote = mongoose.model 'Vote'
@votedOnTeamIds (err, votedOn) =>
next err if err
+
+ if @judge and votedOn.length < 15
+ # judges focus on good stuff
+ filter['$or'] = [
+ 'scores.judge_count': { $lt: 4 }
+ 'scores.judge_utility': { $gt: 3 }
+ 'scores.judge_design': { $gt: 3 }
+ 'scores.judge_innovation': { $gt: 3 }
+ 'scores.judge_completeness': { $gt: 3 }
+ ]
+
+
# every third vote should be for something good
- # if votedOn.length % 3 is 0
- # sort.unshift ['scores.overall', -1]
+ if votedOn.length % 3 is 0
+ dimensions = Vote.dimensions.concat('overall')
+ dimension = dimensions[Math.floor(Math.random() * dimensions.length)]
+
+ sort.unshift ["scores.#{dimension}", -1]
# not already voted on or skipped
filter._id = $nin: votedOn.concat @skippedTeamIds

0 comments on commit f49dfbe

Please sign in to comment.