mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-28 01:55:38 -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,7 +252,10 @@ module.exports = class LadderTabView extends CocoView
|
|||
|
||||
message = "#{histogramData.length} players"
|
||||
if @leaderboards[teamName].session?
|
||||
if @leaderboards[teamName].myRank <= 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!'
|
||||
|
@ -325,9 +328,10 @@ 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
|
||||
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))
|
||||
|
@ -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,14 +167,19 @@ 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
|
||||
if league
|
||||
valueArray = _.pluck data, (session) -> _.find(session.leagues, leagueID: league)?.stats?.totalScore or 10
|
||||
else
|
||||
valueArray = _.pluck data, 'totalScore'
|
||||
@sendSuccess res, valueArray
|
||||
|
||||
|
|
Loading…
Reference in a new issue