mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-30 10:56:53 -05:00
Fixed #1356.
This commit is contained in:
parent
a8644d030e
commit
4d24233b0d
1 changed files with 19 additions and 16 deletions
|
@ -139,7 +139,7 @@ sendReminderEmailToCandidate = (candidate, sendEmailCallback) ->
|
||||||
log.error "Error sending candidate update reminder email: #{err} with result #{result}" if err
|
log.error "Error sending candidate update reminder email: #{err} with result #{result}" if err
|
||||||
sendEmailCallback null
|
sendEmailCallback null
|
||||||
### End Approved Candidate Update Reminder Task ###
|
### End Approved Candidate Update Reminder Task ###
|
||||||
|
|
||||||
### Unapproved Candidate Finish Reminder Task ###
|
### Unapproved Candidate Finish Reminder Task ###
|
||||||
unapprovedCandidateFinishProfileTask = ->
|
unapprovedCandidateFinishProfileTask = ->
|
||||||
mailTaskName = "unapprovedCandidateFinishProfileTask"
|
mailTaskName = "unapprovedCandidateFinishProfileTask"
|
||||||
|
@ -187,13 +187,13 @@ findAllUnapprovedCandidatesWithinTimeRange = (cb) ->
|
||||||
User.find(findParameters).select(selection).lean().exec cb
|
User.find(findParameters).select(selection).lean().exec cb
|
||||||
|
|
||||||
ignoredCandidateFilter = (candidate, cb) ->
|
ignoredCandidateFilter = (candidate, cb) ->
|
||||||
findParameters =
|
findParameters =
|
||||||
"user": candidate._id
|
"user": candidate._id
|
||||||
"contactName": "Ignore"
|
"contactName": "Ignore"
|
||||||
UserRemark.count findParameters, (err, results) ->
|
UserRemark.count findParameters, (err, results) ->
|
||||||
if err? then return true
|
if err? then return true
|
||||||
return cb Boolean(results.length)
|
return cb Boolean(results.length)
|
||||||
|
|
||||||
unapprovedCandidateFilter = (candidate, sentEmailFilterCallback) ->
|
unapprovedCandidateFilter = (candidate, sentEmailFilterCallback) ->
|
||||||
if candidate.emails?.anyNotes?.enabled is false or candidate.emails?.recruitNotes?.enabled is false
|
if candidate.emails?.anyNotes?.enabled is false or candidate.emails?.recruitNotes?.enabled is false
|
||||||
return sentEmailFilterCallback true
|
return sentEmailFilterCallback true
|
||||||
|
@ -234,7 +234,7 @@ sendReminderEmailToUnapprovedCandidate = (candidate, sendEmailCallback) ->
|
||||||
log.error "Error sending candidate finish profile reminder email: #{err} with result #{result}" if err
|
log.error "Error sending candidate finish profile reminder email: #{err} with result #{result}" if err
|
||||||
sendEmailCallback null
|
sendEmailCallback null
|
||||||
### End Unapproved Candidate Finish Reminder Task ###
|
### End Unapproved Candidate Finish Reminder Task ###
|
||||||
|
|
||||||
### Internal Candidate Update Reminder Email ###
|
### Internal Candidate Update Reminder Email ###
|
||||||
internalCandidateUpdateTask = ->
|
internalCandidateUpdateTask = ->
|
||||||
mailTaskName = "internalCandidateUpdateTask"
|
mailTaskName = "internalCandidateUpdateTask"
|
||||||
|
@ -408,7 +408,7 @@ sendEmployerNewCandidatesAvailableEmail = (employer, cb) ->
|
||||||
cb null
|
cb null
|
||||||
|
|
||||||
### End Employer New Candidates Available Email ###
|
### End Employer New Candidates Available Email ###
|
||||||
|
|
||||||
### Task Emails ###
|
### Task Emails ###
|
||||||
emailUserRemarkTaskRemindersTask = ->
|
emailUserRemarkTaskRemindersTask = ->
|
||||||
mailTaskName = "emailUserRemarkTaskRemindersTask"
|
mailTaskName = "emailUserRemarkTaskRemindersTask"
|
||||||
|
@ -428,7 +428,7 @@ emailUserRemarkTaskReminders = (cb) ->
|
||||||
asyncContext =
|
asyncContext =
|
||||||
"currentTime": currentTime
|
"currentTime": currentTime
|
||||||
"mailTaskName": @mailTaskName
|
"mailTaskName": @mailTaskName
|
||||||
|
|
||||||
async.waterfall [
|
async.waterfall [
|
||||||
findAllIncompleteUserRemarkTasksDue.bind(asyncContext)
|
findAllIncompleteUserRemarkTasksDue.bind(asyncContext)
|
||||||
processRemarksIntoTasks.bind(asyncContext)
|
processRemarksIntoTasks.bind(asyncContext)
|
||||||
|
@ -437,9 +437,9 @@ emailUserRemarkTaskReminders = (cb) ->
|
||||||
(tasksToRemind, cb) ->
|
(tasksToRemind, cb) ->
|
||||||
async.each tasksToRemind, sendUserRemarkTaskEmail.bind(asyncContext), cb
|
async.each tasksToRemind, sendUserRemarkTaskEmail.bind(asyncContext), cb
|
||||||
], cb
|
], cb
|
||||||
|
|
||||||
findAllIncompleteUserRemarkTasksDue = (cb) ->
|
findAllIncompleteUserRemarkTasksDue = (cb) ->
|
||||||
findParameters =
|
findParameters =
|
||||||
tasks:
|
tasks:
|
||||||
$exists: true
|
$exists: true
|
||||||
$elemMatch:
|
$elemMatch:
|
||||||
|
@ -449,12 +449,12 @@ findAllIncompleteUserRemarkTasksDue = (cb) ->
|
||||||
$ne: 'Completed'
|
$ne: 'Completed'
|
||||||
selection = "contact user tasks"
|
selection = "contact user tasks"
|
||||||
UserRemark.find(findParameters).select(selection).lean().exec cb
|
UserRemark.find(findParameters).select(selection).lean().exec cb
|
||||||
|
|
||||||
processRemarksIntoTasks = (remarks, cb) ->
|
processRemarksIntoTasks = (remarks, cb) ->
|
||||||
tasks = []
|
tasks = []
|
||||||
for remark in remarks
|
for remark in remarks
|
||||||
for task in remark.tasks
|
for task in remark.tasks
|
||||||
taskObject =
|
taskObject =
|
||||||
date: task.date
|
date: task.date
|
||||||
action: task.action
|
action: task.action
|
||||||
contact: remark.contact
|
contact: remark.contact
|
||||||
|
@ -476,7 +476,7 @@ taskReminderAlreadySentThisWeekFilter = (task, cb) ->
|
||||||
MailSent.count findParameters, (err, count) ->
|
MailSent.count findParameters, (err, count) ->
|
||||||
if err? then return cb true
|
if err? then return cb true
|
||||||
return cb Boolean(count)
|
return cb Boolean(count)
|
||||||
|
|
||||||
sendUserRemarkTaskEmail = (task, cb) ->
|
sendUserRemarkTaskEmail = (task, cb) ->
|
||||||
mailTaskName = @mailTaskName
|
mailTaskName = @mailTaskName
|
||||||
User.findOne("_id":task.contact).select("email").lean().exec (err, contact) ->
|
User.findOne("_id":task.contact).select("email").lean().exec (err, contact) ->
|
||||||
|
@ -548,8 +548,8 @@ isRequestFromDesignatedCronHandler = (req, res) ->
|
||||||
|
|
||||||
handleLadderUpdate = (req, res) ->
|
handleLadderUpdate = (req, res) ->
|
||||||
log.info('Going to see about sending ladder update emails.')
|
log.info('Going to see about sending ladder update emails.')
|
||||||
requestIsFromDesignatedCronHandler = isRequestFromDesignatedCronHandler req, res
|
requestIsFromDesignatedCronHandler = DEBUGGING or isRequestFromDesignatedCronHandler req, res
|
||||||
return unless requestIsFromDesignatedCronHandler or DEBUGGING
|
return unless requestIsFromDesignatedCronHandler
|
||||||
|
|
||||||
res.send('Great work, Captain Cron! I can take it from here.')
|
res.send('Great work, Captain Cron! I can take it from here.')
|
||||||
res.end()
|
res.end()
|
||||||
|
@ -564,7 +564,7 @@ handleLadderUpdate = (req, res) ->
|
||||||
endTime = startTime + 15 * 60 * 1000 # Debugging: make sure there's something to send
|
endTime = startTime + 15 * 60 * 1000 # Debugging: make sure there's something to send
|
||||||
findParameters = {submitted: true, submitDate: {$gt: new Date(startTime), $lte: new Date(endTime)}}
|
findParameters = {submitted: true, submitDate: {$gt: new Date(startTime), $lte: new Date(endTime)}}
|
||||||
# TODO: think about putting screenshots in the email
|
# TODO: think about putting screenshots in the email
|
||||||
selectString = 'creator team levelName levelID totalScore matches submitted submitDate scoreHistory'
|
selectString = 'creator team levelName levelID totalScore matches submitted submitDate scoreHistory level.original'
|
||||||
query = LevelSession.find(findParameters)
|
query = LevelSession.find(findParameters)
|
||||||
.select(selectString)
|
.select(selectString)
|
||||||
.lean()
|
.lean()
|
||||||
|
@ -600,7 +600,7 @@ sendLadderUpdateEmail = (session, now, daysAgo) ->
|
||||||
defeat = _.last defeats
|
defeat = _.last defeats
|
||||||
victory = _.last victories
|
victory = _.last victories
|
||||||
|
|
||||||
sendEmail = (defeatContext, victoryContext) ->
|
sendEmail = (defeatContext, victoryContext, levelVersionsContext) ->
|
||||||
# TODO: do something with the preferredLanguage?
|
# TODO: do something with the preferredLanguage?
|
||||||
context =
|
context =
|
||||||
email_id: sendwithus.templates.ladder_update_email
|
email_id: sendwithus.templates.ladder_update_email
|
||||||
|
@ -621,6 +621,7 @@ sendLadderUpdateEmail = (session, now, daysAgo) ->
|
||||||
score_history_graph_url: getScoreHistoryGraphURL session, daysAgo
|
score_history_graph_url: getScoreHistoryGraphURL session, daysAgo
|
||||||
defeat: defeatContext
|
defeat: defeatContext
|
||||||
victory: victoryContext
|
victory: victoryContext
|
||||||
|
levelVersions: levelVersionsContext
|
||||||
log.info "Sending ladder update email to #{context.recipient.address} with #{context.email_data.wins} wins and #{context.email_data.losses} losses since #{daysAgo} day(s) ago."
|
log.info "Sending ladder update email to #{context.recipient.address} with #{context.email_data.wins} wins and #{context.email_data.losses} losses since #{daysAgo} day(s) ago."
|
||||||
sendwithus.api.send context, (err, result) ->
|
sendwithus.api.send context, (err, result) ->
|
||||||
log.error "Error sending ladder update email: #{err} with result #{result}" if err
|
log.error "Error sending ladder update email: #{err} with result #{result}" if err
|
||||||
|
@ -639,7 +640,9 @@ sendLadderUpdateEmail = (session, now, daysAgo) ->
|
||||||
log.error "Couldn't find victorious opponent: #{err}"
|
log.error "Couldn't find victorious opponent: #{err}"
|
||||||
victoriousOpponent = null
|
victoriousOpponent = null
|
||||||
defeatContext = {opponent_name: victoriousOpponent?.name ? 'Anoner', url: urlForMatch(defeat)} if defeat
|
defeatContext = {opponent_name: victoriousOpponent?.name ? 'Anoner', url: urlForMatch(defeat)} if defeat
|
||||||
sendEmail defeatContext, victoryContext
|
|
||||||
|
Level.find({original: session.level.original, created: {$gt: session.submitDate}}).select('created commitMessage version').sort('-created').lean().exec (err, levelVersions) ->
|
||||||
|
sendEmail defeatContext, victoryContext, (if levelVersions.length then levelVersions else null)
|
||||||
|
|
||||||
if defeat
|
if defeat
|
||||||
User.findOne({_id: defeat.opponents[0].userID}).select('name').lean().exec onFetchedVictoriousOpponent
|
User.findOne({_id: defeat.opponents[0].userID}).select('name').lean().exec onFetchedVictoriousOpponent
|
||||||
|
|
Loading…
Reference in a new issue