Skip to content
Newer
Older
100644 22 lines (19 sloc) 842 Bytes
12b7ece @gerad nag judges some more
gerad authored Sep 3, 2011
1 require 'colors'
2 env = require '../config/env'
3 mongoose = require('../models')(env.mongo_url)
4 util = require 'util'
5 postageapp = require('postageapp')(env.secrets.postageapp)
6
7 Vote = mongoose.model 'Vote'
8 Person = mongoose.model 'Person'
9
10 Person.find { role: 'judge', email: /@/, twitterScreenName: /\w/ }, (err, judges) ->
11 throw err if err
12 judges.forEach (judge) ->
13 Vote.count { personId: judge.id }, (err, count) ->
14 throw err if err
15 votes_left = 10 - count
16 if votes_left > 0
17 util.log "Sending 'judge_nag_two' to '#{judge.email}' (#{count})".yellow
18 postageapp.apiCall judge.email, 'judge_nag_two', null, null,
19 first_name: judge.name.split(/\s/)[0]
20 votes_left: if votes_left is 1 then '1 vote' else "#{votes_left} votes"
21 else util.log "Skipping '#{judge.email}' (#{count})"
Something went wrong with that request. Please try again.