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

Method fetch

app/views/ladder/SimulateTabView.js:173–201  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

171 }
172
173 fetch () {
174 const promises = []
175 if (!this.me.get('anonymous')) {
176 const queueSuccess = numberOfGamesInQueue => {
177 this.numberOfGamesInQueue = numberOfGamesInQueue
178 }
179 promises.push($.ajax('/db/level/-/ladder-match-queue-count', { success: queueSuccess, cache: false }))
180 }
181 if (!this.level.isType('ladder') && me.isAdmin()) {
182 this.topSimulators = new SimulatorsLeaderboardCollection({ order: -1, scoreOffset: -1, limit: 20 })
183 promises.push(this.topSimulators.fetch())
184 const score = this.me.get('simulatedBy') || 0
185 this.playersAbove = new SimulatorsLeaderboardCollection({ order: 1, scoreOffset: score, limit: 4 })
186 promises.push(this.playersAbove.fetch())
187 if (score) {
188 this.playersBelow = new SimulatorsLeaderboardCollection({ order: -1, scoreOffset: score, limit: 4 })
189 promises.push(this.playersBelow.fetch())
190 }
191 const success = myRank => {
192 this.myRank = myRank
193 }
194 promises.push($.ajax(`/db/user/me/simulator_leaderboard_rank?scoreOffset=${score}`, { cache: false, success }))
195 }
196
197 this.promise = $.when(...Array.from(promises || []))
198 this.promise.then(this.onLoad)
199 this.promise.fail(this.onFail)
200 return this.promise
201 }
202
203 onLoad () {
204 if (this.destroyed) { return }

Callers

nothing calls this directly

Calls 4

isTypeMethod · 0.80
isAdminMethod · 0.80
failMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected