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

Function codePointsRankings

app/core/store/modules/seasonalLeague.js:262–298  ·  view source on GitHub ↗
(state)

Source from the content-addressed store, hash-verified

260 },
261
262 codePointsRankings (state) {
263 return (leagueId) => {
264 if (!state.codePointsRankingsForLeague[leagueId]) {
265 return []
266 }
267 const codePointsRankings = state.codePointsRankingsForLeague[leagueId]
268 try {
269 if (state.myCodePointsRank && state.myCodePointsRank.rank > 20) {
270 const splitRankings = []
271 splitRankings.push(...codePointsRankings.top.slice(0, 10))
272 splitRankings.push({ type: 'BLANK_ROW' })
273 splitRankings.push(...codePointsRankings.playersAbove)
274 splitRankings.push(state.myCodePointsRank)
275 splitRankings.push(...codePointsRankings.playersBelow)
276 return splitRankings
277 }
278
279 if (state.myCodePointsRank && typeof state.myCodePointsRank.rank === 'number' && state.myCodePointsRank.rank <= 20) {
280 // This patches in the correct name and id if you are in the top 20.
281 const rankIdx = state.myCodePointsRank.rank - 1
282 const top = [...codePointsRankings.top]
283 top[rankIdx] = {
284 ...codePointsRankings.top[rankIdx],
285 creator: me.id,
286 creatorName: me.broadName()
287 }
288 return top
289 }
290
291 return codePointsRankings.top
292 } catch (e) {
293 // TODO - handle correctly. This is a hack to avoid strange situations as we are going fast.
294 console.error(e)
295 }
296 return []
297 }
298 },
299 codePointsPlayerCount (state) {
300 return state.codePointsRankingsForLeague.playerCount
301 },

Callers

nothing calls this directly

Calls 2

broadNameMethod · 0.80
errorMethod · 0.45

Tested by

no test coverage detected