mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-05-02 00:43:34 -04:00
Various improvements to transpire script
This commit is contained in:
parent
eba3f36f0b
commit
435ec1b6aa
1 changed files with 9 additions and 6 deletions
|
@ -11,25 +11,28 @@ LevelSession = require '../server/levels/sessions/LevelSession.coffee'
|
||||||
|
|
||||||
Aether.addGlobal 'Vector', require '../app/lib/world/vector'
|
Aether.addGlobal 'Vector', require '../app/lib/world/vector'
|
||||||
Aether.addGlobal '_', _
|
Aether.addGlobal '_', _
|
||||||
|
i = 0
|
||||||
transpileLevelSession = (sessionID, cb) ->
|
transpileLevelSession = (sessionID, cb) ->
|
||||||
query = LevelSession.findOne("_id": sessionID).select("submittedCode submittedCodeLanguage").lean()
|
query = LevelSession.findOne("_id": sessionID).select("team teamSpells submittedCode submittedCodeLanguage").lean()
|
||||||
query.exec (err, session) ->
|
query.exec (err, session) ->
|
||||||
if err then return cb err
|
if err then return cb err
|
||||||
submittedCode = session.submittedCode
|
submittedCode = session.submittedCode
|
||||||
unless session.submittedCodeLanguage
|
unless session.submittedCodeLanguage
|
||||||
throw "SUBMITTED CODE LANGUAGE DOESN'T EXIST"
|
throw "SUBMITTED CODE LANGUAGE DOESN'T EXIST"
|
||||||
else
|
else
|
||||||
console.log "Transpiling code for session #{session._id} in language #{session.submittedCodeLanguage}"
|
console.log "Transpiling code for session #{i++} #{session._id} in language #{session.submittedCodeLanguage}"
|
||||||
transpiledCode = {}
|
transpiledCode = {}
|
||||||
#console.log "Updating session #{sessionID}"
|
#console.log "Updating session #{sessionID}"
|
||||||
for thang, spells of submittedCode
|
for thang, spells of submittedCode
|
||||||
transpiledCode[thang] = {}
|
transpiledCode[thang] = {}
|
||||||
for spellID, spell of spells
|
for spellID, spell of spells
|
||||||
|
spellName = thang + "/" + spellID
|
||||||
|
|
||||||
|
if session.teamSpells and not (spellName in session.teamSpells[session.team]) then continue
|
||||||
|
#console.log "Transpiling spell #{spellName}"
|
||||||
aetherOptions =
|
aetherOptions =
|
||||||
problems: {}
|
problems: {}
|
||||||
language: session.submittedCodeLanguage
|
language: session.submittedCodeLanguage
|
||||||
functionName: spellID
|
functionName: spellID
|
||||||
functionParameters: []
|
functionParameters: []
|
||||||
yieldConditionally: spellID is "plan"
|
yieldConditionally: spellID is "plan"
|
||||||
|
@ -62,7 +65,7 @@ findLadderLevelSessions = (levelID, cb) ->
|
||||||
levelSessionIDs = _.pluck levelSessions, "_id"
|
levelSessionIDs = _.pluck levelSessions, "_id"
|
||||||
async.eachSeries levelSessionIDs, transpileLevelSession, (err) ->
|
async.eachSeries levelSessionIDs, transpileLevelSession, (err) ->
|
||||||
if err then return cb err
|
if err then return cb err
|
||||||
cb null
|
return cb null
|
||||||
|
|
||||||
|
|
||||||
transpileLadderSessions = ->
|
transpileLadderSessions = ->
|
||||||
|
@ -80,4 +83,4 @@ transpileLadderSessions = ->
|
||||||
throw err if err
|
throw err if err
|
||||||
|
|
||||||
serverSetup.connectToDatabase()
|
serverSetup.connectToDatabase()
|
||||||
transpileLadderSessions()
|
transpileLadderSessions()
|
Loading…
Add table
Add a link
Reference in a new issue