mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-23 23:58:02 -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
|
||||
text-align: center
|
||||
|
||||
&.league-header
|
||||
margin: 15px 0 20px 0
|
||||
|
||||
.tournament-blurb
|
||||
margin-top: -10px
|
||||
margin-bottom: 10px
|
||||
|
|
|
@ -11,7 +11,7 @@ block content
|
|||
h1= level.get('name')
|
||||
|
||||
if league
|
||||
h1
|
||||
h1.league-header
|
||||
a(href="/#{leagueType == 'clan' ? 'clans' : leagueType}/#{league.id}")= league.get('name')
|
||||
span.spl(data-i18n="ladder.league") League
|
||||
|
||||
|
@ -75,7 +75,7 @@ block content
|
|||
a(href="http://discourse.codecombat.com/") the forum
|
||||
| and discuss your strategies, your triumphs, and your turmoils.
|
||||
|
||||
if level.get('name') == 'Zero Sum'
|
||||
if level.get('name') == 'Zero Sum' && !league
|
||||
.tournament-blurb
|
||||
h2
|
||||
span(data-i18n="ladder.tournament_ended") Tournament ended
|
||||
|
|
|
@ -252,10 +252,13 @@ module.exports = class LadderTabView extends CocoView
|
|||
|
||||
message = "#{histogramData.length} players"
|
||||
if @leaderboards[teamName].session?
|
||||
if @leaderboards[teamName].myRank <= histogramData.length
|
||||
message="##{@leaderboards[teamName].myRank} of #{histogramData.length}"
|
||||
if @options.league
|
||||
# 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
|
||||
message='Rank your session!'
|
||||
message = 'Rank your session!'
|
||||
svg.append('g')
|
||||
.append('text')
|
||||
.attr('class', rankClass)
|
||||
|
@ -325,18 +328,19 @@ module.exports.LeaderboardData = LeaderboardData = class LeaderboardData extends
|
|||
|
||||
if @session
|
||||
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
|
||||
score = @session.get('totalScore') or 10
|
||||
@playersAbove = new LeaderboardCollection(@level, @collectionParameters(order: 1, scoreOffset: score, limit: 4))
|
||||
promises.push @playersAbove.fetch cache: false
|
||||
@playersBelow = new LeaderboardCollection(@level, @collectionParameters(order: -1, scoreOffset: score, limit: 4))
|
||||
promises.push @playersBelow.fetch cache: false
|
||||
level = "#{@level.get('original')}.#{@level.get('version').major}"
|
||||
success = (@myRank) =>
|
||||
loadURL = "/db/level/#{level}/leaderboard_rank?scoreOffset=#{score}&team=#{@team}"
|
||||
loadURL += '&leagues.leagueID=' + @league.id if @league
|
||||
promises.push $.ajax(loadURL, cache: false, success: success)
|
||||
score = @session.get('totalScore')
|
||||
if score
|
||||
@playersAbove = new LeaderboardCollection(@level, @collectionParameters(order: 1, scoreOffset: score, limit: 4))
|
||||
promises.push @playersAbove.fetch cache: false
|
||||
@playersBelow = new LeaderboardCollection(@level, @collectionParameters(order: -1, scoreOffset: score, limit: 4))
|
||||
promises.push @playersBelow.fetch cache: false
|
||||
level = "#{@level.get('original')}.#{@level.get('version').major}"
|
||||
success = (@myRank) =>
|
||||
loadURL = "/db/level/#{level}/leaderboard_rank?scoreOffset=#{score}&team=#{@team}"
|
||||
loadURL += '&leagues.leagueID=' + @league.id if @league
|
||||
promises.push $.ajax(loadURL, cache: false, success: success)
|
||||
@promise = $.when(promises...)
|
||||
@promise.then @onLoad
|
||||
@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)
|
||||
|
||||
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 = []
|
||||
above = @playersAbove.models
|
||||
l = l.concat(above)
|
||||
|
|
|
@ -167,15 +167,20 @@ LevelHandler = class LevelHandler extends Handler
|
|||
getHistogramData: (req, res, slug) ->
|
||||
match = levelID: slug, submitted: true, team: req.query.team
|
||||
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 [
|
||||
{$match: match}
|
||||
{$project: {totalScore: 1, _id: 0}}
|
||||
{$project: project}
|
||||
]
|
||||
aggregate.cache() unless league
|
||||
|
||||
aggregate.exec (err, data) =>
|
||||
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
|
||||
|
||||
checkExistence: (req, res, slugOrID) ->
|
||||
|
|
Loading…
Reference in a new issue