MCPcopy Create free account
hub / github.com/codecombat/codecombat / refreshLadder

Method refreshLadder

app/views/ladder/LadderTabView.js:231–253  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

229 // LADDER LOADING
230
231 refreshLadder () {
232 // Only do this so often if not in a league; servers cache a lot of this data for a few minutes anyway.
233 if (!this.options.league && ((new Date() - (2 * 60 * 1000)) < this.lastRefreshTime)) { return }
234 this.lastRefreshTime = new Date()
235 this.supermodel.resetProgress()
236 if (this.ladderLimit == null) { this.ladderLimit = parseInt(utils.getQueryVariable('top_players', this.options.league ? 100 : 20)) }
237 return (() => {
238 const result = []
239 for (var team of Array.from(this.teams)) {
240 var oldLeaderboard
241 if (oldLeaderboard = this.leaderboards[team.id]) {
242 this.supermodel.removeModelResource(oldLeaderboard)
243 oldLeaderboard.destroy()
244 }
245 const teamSession = _.find(this.sessions.models, session => session.get('team') === team.id)
246 this.leaderboards[team.id] = new LeaderboardData(this.level, team.id, teamSession, this.ladderLimit, this.options.league, this.tournamentId)
247 team.leaderboard = this.leaderboards[team.id]
248 this.leaderboardRes = this.supermodel.addModelResource(this.leaderboards[team.id], 'leaderboard', { cache: false }, 3)
249 result.push(this.leaderboardRes.load())
250 }
251 return result
252 })()
253 }
254
255 render () {
256 super.render()

Callers 3

constructorMethod · 0.95
refreshViewsMethod · 0.45

Calls 4

resetProgressMethod · 0.80
destroyMethod · 0.45
getMethod · 0.45
loadMethod · 0.45

Tested by

no test coverage detected