mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-24 08:08:15 -05:00
Fixed issues with level previews and localStorage model loading. Disabled break animations on code error for now. Stopped multiple ThangType load on multiple missiles. Stopped trying to connect to Redis on local production setup.
This commit is contained in:
parent
0561235da2
commit
6b028513fd
5 changed files with 45 additions and 43 deletions
|
@ -82,7 +82,7 @@ module.exports = CocoSprite = class CocoSprite extends CocoClass
|
|||
if @thangType.isFullyLoaded()
|
||||
@setupSprite()
|
||||
else
|
||||
@thangType.fetch()
|
||||
@thangType.fetch() unless @thangType.loading
|
||||
@listenToOnce(@thangType, 'sync', @setupSprite)
|
||||
|
||||
setupSprite: ->
|
||||
|
@ -442,7 +442,7 @@ module.exports = CocoSprite = class CocoSprite extends CocoClass
|
|||
console.warn 'Cannot show action', action, 'for', @thangType.get('name'), 'because it DNE' unless @warnedFor[action]
|
||||
@warnedFor[action] = true
|
||||
return if @action is 'idle' then null else 'idle'
|
||||
action = 'break' if @actions.break? and @thang?.erroredOut
|
||||
#action = 'break' if @actions.break? and @thang?.erroredOut # This makes it looks like it's dead when it's not: bad in Brawlwood.
|
||||
action = 'die' if @actions.die? and thang?.health? and thang.health <= 0
|
||||
@actions[action]
|
||||
|
||||
|
|
|
@ -115,7 +115,8 @@ module.exports = Surface = class Surface extends CocoClass
|
|||
|
||||
setWorld: (@world) ->
|
||||
@worldLoaded = true
|
||||
@world.getFrame(Math.min(@getCurrentFrame(), @world.totalFrames - 1)).restoreState() unless @options.choosing
|
||||
lastFrame = Math.min(@getCurrentFrame(), @world.totalFrames - 1)
|
||||
@world.getFrame(lastFrame).restoreState() unless @options.choosing
|
||||
@spriteBoss.world = @world
|
||||
|
||||
@showLevel()
|
||||
|
@ -241,7 +242,7 @@ module.exports = Surface = class Surface extends CocoClass
|
|||
@onFrameChanged()
|
||||
|
||||
getCurrentFrame: ->
|
||||
return Math.max(0, Math.min(Math.floor(@currentFrame), @world.totalFrames - 1))
|
||||
return Math.max(0, Math.min(Math.floor(@currentFrame), @world.frames.length - 1))
|
||||
|
||||
getProgress: -> @currentFrame / @world.totalFrames
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ module.exports = class EditorLevelView extends View
|
|||
constructor: (options, @levelID) ->
|
||||
super options
|
||||
@supermodel.shouldSaveBackups = (model) ->
|
||||
model.constructor.className in ['Level', 'LevelComponent', 'LevelSystem']
|
||||
model.constructor.className in ['Level', 'LevelComponent', 'LevelSystem', 'ThangType']
|
||||
@levelLoader = new LevelLoader supermodel: @supermodel, levelID: @levelID, headless: true, editorMode: true
|
||||
@level = @levelLoader.level
|
||||
@files = new DocumentFiles(@levelLoader.level)
|
||||
|
|
|
@ -84,8 +84,9 @@ module.exports = class PlayLevelView extends View
|
|||
@saveScreenshot = _.throttle @saveScreenshot, 30000
|
||||
|
||||
if @isEditorPreview
|
||||
# wait to see if it's just given to us through setLevel
|
||||
f = => @load() unless @levelLoader
|
||||
@supermodel.shouldSaveBackups = (model) -> # Make sure to load possibly changed things from localStorage.
|
||||
model.constructor.className in ['Level', 'LevelComponent', 'LevelSystem', 'ThangType']
|
||||
f = => @load() unless @levelLoader # Wait to see if it's just given to us through setLevel.
|
||||
setTimeout f, 100
|
||||
else
|
||||
@load()
|
||||
|
|
|
@ -8,15 +8,15 @@ LevelSession = require '../levels/sessions/LevelSession'
|
|||
Level = require '../levels/Level'
|
||||
log = require 'winston'
|
||||
sendwithus = require '../sendwithus'
|
||||
if config.isProduction
|
||||
if config.isProduction and config.redis.host isnt 'localhost'
|
||||
lockManager = require '../commons/LockManager'
|
||||
|
||||
|
||||
module.exports.setup = (app) ->
|
||||
app.all config.mail.mailchimpWebhook, handleMailchimpWebHook
|
||||
app.get '/mail/cron/ladder-update', handleLadderUpdate
|
||||
if lockManager
|
||||
setupScheduledEmails()
|
||||
|
||||
|
||||
setupScheduledEmails = ->
|
||||
testForLockManager()
|
||||
mailTasks = [
|
||||
|
@ -31,15 +31,15 @@ setupScheduledEmails = ->
|
|||
]
|
||||
|
||||
for mailTask in mailTasks
|
||||
setInterval mailTask.taskFunction, mailTask.frequencyMs
|
||||
|
||||
setInterval mailTask.taskFunction, mailTask.frequencyMs
|
||||
|
||||
testForLockManager = -> unless lockManager then throw "The system isn't configured to do distributed locking!"
|
||||
|
||||
|
||||
### Candidate Update Reminder Task ###
|
||||
|
||||
candidateUpdateProfileTask = ->
|
||||
mailTaskName = "candidateUpdateProfileTask"
|
||||
lockDurationMs = 2 * 60 * 1000
|
||||
lockDurationMs = 2 * 60 * 1000
|
||||
currentDate = new Date()
|
||||
timeRanges = []
|
||||
for weekPair in [[4, 2,'two weeks'], [8, 4, 'four weeks'], [52, 8, 'eight weeks']]
|
||||
|
@ -66,12 +66,12 @@ emailTimeRange = (timeRange, emailTimeRangeCallback) ->
|
|||
"mailTaskName": @mailTaskName
|
||||
async.waterfall [
|
||||
findAllCandidatesWithinTimeRange.bind(waterfallContext)
|
||||
(unfilteredCandidates, cb) ->
|
||||
(unfilteredCandidates, cb) ->
|
||||
async.reject unfilteredCandidates, candidateFilter.bind(waterfallContext), cb.bind(null, null)
|
||||
(filteredCandidates, cb) ->
|
||||
async.each filteredCandidates, sendReminderEmailToCandidate.bind(waterfallContext), cb
|
||||
], emailTimeRangeCallback
|
||||
|
||||
|
||||
findAllCandidatesWithinTimeRange = (cb) ->
|
||||
findParameters =
|
||||
"jobProfile.updated":
|
||||
|
@ -80,7 +80,7 @@ findAllCandidatesWithinTimeRange = (cb) ->
|
|||
"jobProfileApproved": true
|
||||
selection = "_id email jobProfile.name jobProfile.updated emails" #make sure to check for anyNotes too.
|
||||
User.find(findParameters).select(selection).lean().exec cb
|
||||
|
||||
|
||||
candidateFilter = (candidate, sentEmailFilterCallback) ->
|
||||
if candidate.emails?.anyNotes?.enabled is false or candidate.emails?.recruitNotes?.enabled is false
|
||||
return sentEmailFilterCallback true
|
||||
|
@ -102,7 +102,7 @@ findEmployersSignedUpAfterDate = (dateObject, cb) ->
|
|||
employerAt: {$exists: true}
|
||||
permissions: "employer"
|
||||
User.count countParameters, cb
|
||||
|
||||
|
||||
sendReminderEmailToCandidate = (candidate, sendEmailCallback) ->
|
||||
findEmployersSignedUpAfterDate new Date(candidate.jobProfile.updated), (err, employersAfterCount) =>
|
||||
if err?
|
||||
|
@ -136,7 +136,7 @@ sendReminderEmailToCandidate = (candidate, sendEmailCallback) ->
|
|||
### Internal Candidate Update Reminder Email ###
|
||||
internalCandidateUpdateTask = ->
|
||||
mailTaskName = "internalCandidateUpdateTask"
|
||||
lockDurationMs = 2 * 60 * 1000
|
||||
lockDurationMs = 2 * 60 * 1000
|
||||
lockManager.setLock mailTaskName, lockDurationMs, (err) ->
|
||||
if err? then return log.error "Error getting a distributed lock for task #{mailTaskName}: #{err}"
|
||||
emailInternalCandidateUpdateReminder.call {"mailTaskName":mailTaskName}, (err) ->
|
||||
|
@ -162,31 +162,31 @@ emailInternalCandidateUpdateReminder = (internalCandidateUpdateReminderCallback)
|
|||
(filteredCandidates, cb) ->
|
||||
async.each filteredCandidates, sendInternalCandidateUpdateReminder.bind(asyncContext), cb
|
||||
], internalCandidateUpdateReminderCallback
|
||||
|
||||
|
||||
findNonApprovedCandidatesWhoUpdatedJobProfileToday = (cb) ->
|
||||
findParameters =
|
||||
findParameters =
|
||||
"jobProfile.updated":
|
||||
$lte: @currentTime.toISOString()
|
||||
$gt: @beginningOfUTCDay.toISOString()
|
||||
"jobProfileApproved": false
|
||||
"jobProfileApproved": false
|
||||
User.find(findParameters).select("_id jobProfile.name jobProfile.updated").lean().exec cb
|
||||
|
||||
|
||||
candidatesUpdatedTodayFilter = (candidate, cb) ->
|
||||
findParameters =
|
||||
"user": candidate._id
|
||||
"mailTask": @mailTaskName
|
||||
"metadata.beginningOfUTCDay": @beginningOfUTCDay
|
||||
"metadata.beginningOfUTCDay": @beginningOfUTCDay
|
||||
MailSent.find(findParameters).lean().exec (err, sentMail) ->
|
||||
if err?
|
||||
log.error "Error finding mail sent for task #{@mailTaskName} and user #{candidate._id}!"
|
||||
cb true
|
||||
else
|
||||
cb Boolean(sentMail.length)
|
||||
|
||||
|
||||
sendInternalCandidateUpdateReminder = (candidate, cb) ->
|
||||
context =
|
||||
email_id: "tem_Ac7nhgKqatTHBCgDgjF5pE"
|
||||
recipient:
|
||||
recipient:
|
||||
address: "team@codecombat.com"
|
||||
name: "The CodeCombat Team"
|
||||
email_data:
|
||||
|
@ -197,7 +197,7 @@ sendInternalCandidateUpdateReminder = (candidate, cb) ->
|
|||
user: candidate._id
|
||||
metadata:
|
||||
beginningOfUTCDay: @beginningOfUTCDay
|
||||
|
||||
|
||||
MailSent.create newSentMail, (err) ->
|
||||
if err? then return cb err
|
||||
sendwithus.api.send context, (err, result) ->
|
||||
|
@ -208,7 +208,7 @@ sendInternalCandidateUpdateReminder = (candidate, cb) ->
|
|||
### Employer New Candidates Available Email ###
|
||||
employerNewCandidatesAvailableTask = ->
|
||||
mailTaskName = "employerNewCandidatesAvailableTask"
|
||||
lockDurationMs = 2 * 60 * 1000
|
||||
lockDurationMs = 2 * 60 * 1000
|
||||
lockManager.setLock mailTaskName, lockDurationMs, (err) ->
|
||||
if err? then return log.error "Error getting a distributed lock for task #{mailTaskName}: #{err}"
|
||||
emailEmployerNewCandidatesAvailable.call {"mailTaskName":mailTaskName}, (err) ->
|
||||
|
@ -221,10 +221,10 @@ employerNewCandidatesAvailableTask = ->
|
|||
|
||||
emailEmployerNewCandidatesAvailable = (emailEmployerNewCandidatesAvailableCallback) ->
|
||||
currentTime = new Date()
|
||||
asyncContext =
|
||||
asyncContext =
|
||||
"currentTime": currentTime
|
||||
"mailTaskName": @mailTaskName
|
||||
|
||||
|
||||
async.waterfall [
|
||||
findAllEmployers
|
||||
makeEmployerNamesEasilyAccessible
|
||||
|
@ -233,15 +233,15 @@ emailEmployerNewCandidatesAvailable = (emailEmployerNewCandidatesAvailableCallba
|
|||
(employersToEmail, cb) ->
|
||||
async.each employersToEmail, sendEmployerNewCandidatesAvailableEmail.bind(asyncContext), cb
|
||||
], emailEmployerNewCandidatesAvailableCallback
|
||||
|
||||
|
||||
findAllEmployers = (cb) ->
|
||||
findParameters =
|
||||
findParameters =
|
||||
"employerAt":
|
||||
$exists: true
|
||||
$exists: true
|
||||
permissions: "employer"
|
||||
selection = "_id email employerAt signedEmployerAgreement.data.firstName signedEmployerAgreement.data.lastName activity dateCreated emails"
|
||||
User.find(findParameters).select(selection).lean().exec cb
|
||||
|
||||
|
||||
makeEmployerNamesEasilyAccessible = (allEmployers, cb) ->
|
||||
for employer, index in allEmployers
|
||||
if employer.signedEmployerAgreement?.data?.firstName
|
||||
|
@ -249,17 +249,17 @@ makeEmployerNamesEasilyAccessible = (allEmployers, cb) ->
|
|||
delete employer.signedEmployerAgreement
|
||||
allEmployers[index] = employer
|
||||
cb null, allEmployers
|
||||
|
||||
|
||||
employersEmailedDigestMoreThanWeekAgoFilter = (employer, cb) ->
|
||||
if employer.emails?.employerNotes?.enabled is false
|
||||
return cb true
|
||||
if not employer.signedEmployerAgreement and not employer.activity?.login?
|
||||
return cb true
|
||||
findParameters =
|
||||
findParameters =
|
||||
"user": employer._id
|
||||
"mailTask": @mailTaskName
|
||||
"sent":
|
||||
$gt: new Date(@currentTime.getTime() - 7 * 24 * 60 * 60 * 1000)
|
||||
$gt: new Date(@currentTime.getTime() - 7 * 24 * 60 * 60 * 1000)
|
||||
MailSent.find(findParameters).lean().exec (err, sentMail) ->
|
||||
if err?
|
||||
log.error "Error finding mail sent for task #{@mailTaskName} and employer #employer._id}!"
|
||||
|
@ -268,17 +268,17 @@ employersEmailedDigestMoreThanWeekAgoFilter = (employer, cb) ->
|
|||
cb Boolean(sentMail.length)
|
||||
|
||||
sendEmployerNewCandidatesAvailableEmail = (employer, cb) ->
|
||||
lastLoginDate = employer.activity?.login?.last ? employer.dateCreated
|
||||
lastLoginDate = employer.activity?.login?.last ? employer.dateCreated
|
||||
countParameters =
|
||||
"jobProfileApproved": true
|
||||
$or: [
|
||||
jobProfileApprovedDate:
|
||||
jobProfileApprovedDate:
|
||||
$gt: lastLoginDate.toISOString()
|
||||
,
|
||||
jobProfileApprovedDate:
|
||||
$exists: false
|
||||
"jobProfile.updated":
|
||||
$gt: lastLoginDate.toISOString()
|
||||
$gt: lastLoginDate.toISOString()
|
||||
]
|
||||
User.count countParameters, (err, numberOfCandidatesSinceLogin) =>
|
||||
if err? then return cb err
|
||||
|
@ -315,8 +315,8 @@ newRecruitLeaderboardEmailTask = ->
|
|||
lockManager.setLock mailTaskName, lockDurationMs, (err, lockResult) ->
|
||||
###
|
||||
### End New Recruit Leaderboard Email ###
|
||||
|
||||
### Employer Matching Candidate Notification Email ###
|
||||
|
||||
### Employer Matching Candidate Notification Email ###
|
||||
###
|
||||
employerMatchingCandidateNotificationTask = ->
|
||||
# tem_mYsepTfWQ265noKfZJcbBH
|
||||
|
@ -344,7 +344,7 @@ isRequestFromDesignatedCronHandler = (req, res) ->
|
|||
return true
|
||||
|
||||
|
||||
|
||||
|
||||
handleLadderUpdate = (req, res) ->
|
||||
log.info('Going to see about sending ladder update emails.')
|
||||
requestIsFromDesignatedCronHandler = isRequestFromDesignatedCronHandler req, res
|
||||
|
|
Loading…
Reference in a new issue