mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-24 08:08:15 -05:00
Wins, losses, and realizing that I'm not doing server code right.
This commit is contained in:
parent
2d32bc1ac4
commit
3d71fcbc70
3 changed files with 19 additions and 6 deletions
|
@ -11,11 +11,7 @@ div#columns.row
|
|||
|
||||
tr
|
||||
th(colspan=4, style="color: #{team.primaryColor}")
|
||||
span Your
|
||||
span
|
||||
span= team.name
|
||||
span
|
||||
span Matches
|
||||
span Your #{team.name} Matches - #{team.wins} Wins, #{team.losses} Losses
|
||||
|
||||
if team.session
|
||||
button.btn.btn-sm.btn-warning.pull-right.rank-button(data-session-id=team.session.id)
|
||||
|
|
|
@ -73,6 +73,9 @@ module.exports = class MyMatchesTabView extends CocoView
|
|||
team.matches = (convertMatch(match) for match in team.session?.get('matches') or [])
|
||||
team.matches.reverse()
|
||||
team.score = (team.session?.get('totalScore') or 10).toFixed(2)
|
||||
team.wins = _.filter(team.matches, {state: 'win'}).length
|
||||
team.ties = _.filter(team.matches, {state: 'tie'}).length
|
||||
team.losses = _.filter(team.matches, {state: 'loss'}).length
|
||||
|
||||
ctx
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ errors = require '../commons/errors'
|
|||
#request = require 'request'
|
||||
config = require '../../server_config'
|
||||
LevelSession = require '../levels/sessions/LevelSession.coffee'
|
||||
Level = require '../levels/Level.coffee'
|
||||
log = require 'winston'
|
||||
sendwithus = require '../sendwithus'
|
||||
|
||||
|
@ -16,9 +17,23 @@ module.exports.setup = (app) ->
|
|||
app.all config.mail.mailchimpWebhook, handleMailchimpWebHook
|
||||
app.get '/mail/cron/ladder-update', handleLadderUpdate
|
||||
|
||||
getAllLadderScores = (next) ->
|
||||
query = Level.find({type: 'ladder'})
|
||||
.select('levelID')
|
||||
.lean()
|
||||
query.exec (err, levels) ->
|
||||
if err
|
||||
log.error "Couldn't fetch ladder levels. Error: ", err
|
||||
return next []
|
||||
for level in levels
|
||||
for team in ['humans', 'ogres']
|
||||
'I ... am not doing this.'
|
||||
|
||||
handleLadderUpdate = (req, res) ->
|
||||
log.info("Going to see about sending ladder update emails.")
|
||||
res.send('Great work, Captain Cron! I can take it from here.')
|
||||
res.end()
|
||||
# TODO: somehow fetch the histograms
|
||||
emailDays = [1, 2, 4, 7, 30]
|
||||
now = new Date()
|
||||
getTimeFromDaysAgo = (daysAgo) ->
|
||||
|
@ -35,7 +50,6 @@ handleLadderUpdate = (req, res) ->
|
|||
query = LevelSession.find(findParameters)
|
||||
.select(selectString)
|
||||
.lean()
|
||||
mongoose = require 'mongoose'
|
||||
do (daysAgo) ->
|
||||
query.exec (err, results) ->
|
||||
if err
|
||||
|
|
Loading…
Reference in a new issue