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

Method convertMatch

app/views/ladder/MyMatchesTabView.js:59–80  ·  view source on GitHub ↗
(match, submitDate)

Source from the content-addressed store, hash-verified

57 this.teams = teamDataFromLevel(this.level)
58
59 const convertMatch = (match, submitDate) => {
60 const opponent = match.opponents[0]
61 let state = 'win'
62 if (match.metrics.rank > opponent.metrics.rank) { state = 'loss' }
63 if (match.metrics.rank === opponent.metrics.rank) { state = 'tie' }
64 const fresh = match.date > (new Date(new Date() - (this.refreshDelay * 1000))).toISOString()
65 if (fresh) {
66 this.playSound('chat_received')
67 }
68 return {
69 state,
70 opponentName: this.nameMap[opponent.userID],
71 opponentID: opponent.userID,
72 when: moment(match.date).fromNow(),
73 sessionID: opponent.sessionID,
74 stale: match.date < submitDate,
75 fresh,
76 opTeam: opponent.team,
77 codeLanguage: match.codeLanguage,
78 simulator: match.simulator ? JSON.stringify(match.simulator) + ' | seed ' + match.randomSeed : ''
79 }
80 }
81
82 for (const team of Array.from(this.teams)) {
83 team.session = ((() => {

Callers

nothing calls this directly

Calls 1

stringifyMethod · 0.45

Tested by

no test coverage detected