mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-24 08:08:15 -05:00
Merge branch 'master' into production
This commit is contained in:
commit
86b076fde0
4 changed files with 35 additions and 19 deletions
|
@ -17,6 +17,9 @@
|
||||||
h1
|
h1
|
||||||
text-align: center
|
text-align: center
|
||||||
|
|
||||||
|
&.league-header
|
||||||
|
margin: 15px 0 20px 0
|
||||||
|
|
||||||
.tournament-blurb
|
.tournament-blurb
|
||||||
margin-top: -10px
|
margin-top: -10px
|
||||||
margin-bottom: 10px
|
margin-bottom: 10px
|
||||||
|
|
|
@ -11,7 +11,7 @@ block content
|
||||||
h1= level.get('name')
|
h1= level.get('name')
|
||||||
|
|
||||||
if league
|
if league
|
||||||
h1
|
h1.league-header
|
||||||
a(href="/#{leagueType == 'clan' ? 'clans' : leagueType}/#{league.id}")= league.get('name')
|
a(href="/#{leagueType == 'clan' ? 'clans' : leagueType}/#{league.id}")= league.get('name')
|
||||||
span.spl(data-i18n="ladder.league") League
|
span.spl(data-i18n="ladder.league") League
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ block content
|
||||||
a(href="http://discourse.codecombat.com/") the forum
|
a(href="http://discourse.codecombat.com/") the forum
|
||||||
| and discuss your strategies, your triumphs, and your turmoils.
|
| and discuss your strategies, your triumphs, and your turmoils.
|
||||||
|
|
||||||
if level.get('name') == 'Zero Sum'
|
if level.get('name') == 'Zero Sum' && !league
|
||||||
.tournament-blurb
|
.tournament-blurb
|
||||||
h2
|
h2
|
||||||
span(data-i18n="ladder.tournament_ended") Tournament ended
|
span(data-i18n="ladder.tournament_ended") Tournament ended
|
||||||
|
|
|
@ -252,10 +252,13 @@ module.exports = class LadderTabView extends CocoView
|
||||||
|
|
||||||
message = "#{histogramData.length} players"
|
message = "#{histogramData.length} players"
|
||||||
if @leaderboards[teamName].session?
|
if @leaderboards[teamName].session?
|
||||||
if @leaderboards[teamName].myRank <= histogramData.length
|
if @options.league
|
||||||
message="##{@leaderboards[teamName].myRank} of #{histogramData.length}"
|
# TODO: fix server handler to properly fetch myRank with a leagueID
|
||||||
|
message = "#{histogramData.length} players in league"
|
||||||
|
else if @leaderboards[teamName].myRank <= histogramData.length
|
||||||
|
message = "##{@leaderboards[teamName].myRank} of #{histogramData.length}"
|
||||||
else
|
else
|
||||||
message='Rank your session!'
|
message = 'Rank your session!'
|
||||||
svg.append('g')
|
svg.append('g')
|
||||||
.append('text')
|
.append('text')
|
||||||
.attr('class', rankClass)
|
.attr('class', rankClass)
|
||||||
|
@ -325,18 +328,19 @@ module.exports.LeaderboardData = LeaderboardData = class LeaderboardData extends
|
||||||
|
|
||||||
if @session
|
if @session
|
||||||
if @league
|
if @league
|
||||||
score = _.find(@session.get('leagues'), {leagueID: @league.id})?.stats.totalScore or 10
|
score = _.find(@session.get('leagues'), {leagueID: @league.id})?.stats.totalScore
|
||||||
else
|
else
|
||||||
score = @session.get('totalScore') or 10
|
score = @session.get('totalScore')
|
||||||
@playersAbove = new LeaderboardCollection(@level, @collectionParameters(order: 1, scoreOffset: score, limit: 4))
|
if score
|
||||||
promises.push @playersAbove.fetch cache: false
|
@playersAbove = new LeaderboardCollection(@level, @collectionParameters(order: 1, scoreOffset: score, limit: 4))
|
||||||
@playersBelow = new LeaderboardCollection(@level, @collectionParameters(order: -1, scoreOffset: score, limit: 4))
|
promises.push @playersAbove.fetch cache: false
|
||||||
promises.push @playersBelow.fetch cache: false
|
@playersBelow = new LeaderboardCollection(@level, @collectionParameters(order: -1, scoreOffset: score, limit: 4))
|
||||||
level = "#{@level.get('original')}.#{@level.get('version').major}"
|
promises.push @playersBelow.fetch cache: false
|
||||||
success = (@myRank) =>
|
level = "#{@level.get('original')}.#{@level.get('version').major}"
|
||||||
loadURL = "/db/level/#{level}/leaderboard_rank?scoreOffset=#{score}&team=#{@team}"
|
success = (@myRank) =>
|
||||||
loadURL += '&leagues.leagueID=' + @league.id if @league
|
loadURL = "/db/level/#{level}/leaderboard_rank?scoreOffset=#{score}&team=#{@team}"
|
||||||
promises.push $.ajax(loadURL, cache: false, success: success)
|
loadURL += '&leagues.leagueID=' + @league.id if @league
|
||||||
|
promises.push $.ajax(loadURL, cache: false, success: success)
|
||||||
@promise = $.when(promises...)
|
@promise = $.when(promises...)
|
||||||
@promise.then @onLoad
|
@promise.then @onLoad
|
||||||
@promise.fail @onFail
|
@promise.fail @onFail
|
||||||
|
@ -358,7 +362,11 @@ module.exports.LeaderboardData = LeaderboardData = class LeaderboardData extends
|
||||||
return me.id in (session.attributes.creator for session in @topPlayers.models)
|
return me.id in (session.attributes.creator for session in @topPlayers.models)
|
||||||
|
|
||||||
nearbySessions: ->
|
nearbySessions: ->
|
||||||
return [] unless @session?.get('totalScore')
|
if @league
|
||||||
|
score = _.find(@session?.get('leagues'), {leagueID: @league.id})?.stats.totalScore
|
||||||
|
else
|
||||||
|
score = @session?.get('totalScore')
|
||||||
|
return [] unless score
|
||||||
l = []
|
l = []
|
||||||
above = @playersAbove.models
|
above = @playersAbove.models
|
||||||
l = l.concat(above)
|
l = l.concat(above)
|
||||||
|
|
|
@ -167,15 +167,20 @@ LevelHandler = class LevelHandler extends Handler
|
||||||
getHistogramData: (req, res, slug) ->
|
getHistogramData: (req, res, slug) ->
|
||||||
match = levelID: slug, submitted: true, team: req.query.team
|
match = levelID: slug, submitted: true, team: req.query.team
|
||||||
match['leagues.leagueID'] = league if league = req.query['leagues.leagueID']
|
match['leagues.leagueID'] = league if league = req.query['leagues.leagueID']
|
||||||
|
project = totalScore: 1, _id: 0
|
||||||
|
project['leagues.leagueID'] = project['leagues.stats.totalScore'] = 1 if league
|
||||||
aggregate = Session.aggregate [
|
aggregate = Session.aggregate [
|
||||||
{$match: match}
|
{$match: match}
|
||||||
{$project: {totalScore: 1, _id: 0}}
|
{$project: project}
|
||||||
]
|
]
|
||||||
aggregate.cache() unless league
|
aggregate.cache() unless league
|
||||||
|
|
||||||
aggregate.exec (err, data) =>
|
aggregate.exec (err, data) =>
|
||||||
if err? then return @sendDatabaseError res, err
|
if err? then return @sendDatabaseError res, err
|
||||||
valueArray = _.pluck data, 'totalScore'
|
if league
|
||||||
|
valueArray = _.pluck data, (session) -> _.find(session.leagues, leagueID: league)?.stats?.totalScore or 10
|
||||||
|
else
|
||||||
|
valueArray = _.pluck data, 'totalScore'
|
||||||
@sendSuccess res, valueArray
|
@sendSuccess res, valueArray
|
||||||
|
|
||||||
checkExistence: (req, res, slugOrID) ->
|
checkExistence: (req, res, slugOrID) ->
|
||||||
|
|
Loading…
Reference in a new issue