forked from nko2/website
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Hours of sleep: 25 Cups of coffee: 0 Cans of soda: 0 Cans of redbull: 0
- Loading branch information
Gerad Suyderhoud
committed
Sep 3, 2011
1 parent
079861e
commit 12b7ece
Showing
1 changed file
with
21 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
require 'colors' | ||
env = require '../config/env' | ||
mongoose = require('../models')(env.mongo_url) | ||
util = require 'util' | ||
postageapp = require('postageapp')(env.secrets.postageapp) | ||
|
||
Vote = mongoose.model 'Vote' | ||
Person = mongoose.model 'Person' | ||
|
||
Person.find { role: 'judge', email: /@/, twitterScreenName: /\w/ }, (err, judges) -> | ||
throw err if err | ||
judges.forEach (judge) -> | ||
Vote.count { personId: judge.id }, (err, count) -> | ||
throw err if err | ||
votes_left = 10 - count | ||
if votes_left > 0 | ||
util.log "Sending 'judge_nag_two' to '#{judge.email}' (#{count})".yellow | ||
postageapp.apiCall judge.email, 'judge_nag_two', null, null, | ||
first_name: judge.name.split(/\s/)[0] | ||
votes_left: if votes_left is 1 then '1 vote' else "#{votes_left} votes" | ||
else util.log "Skipping '#{judge.email}' (#{count})" |