mirror of
https://github.com/vkaelin/LeagueStats.git
synced 2026-03-25 12:57:28 +00:00
21 lines
625 B
TypeScript
21 lines
625 B
TypeScript
|
|
import { PlayerRankParsed } from 'App/Parsers/ParsedType'
|
||
|
|
import MatchSerializer from './MatchSerializer'
|
||
|
|
import { SerializedPlayerRanksList } from './SerializedTypes'
|
||
|
|
|
||
|
|
class MatchPlayerRankSerializer extends MatchSerializer {
|
||
|
|
public serialize(ranks: PlayerRankParsed[]): SerializedPlayerRanksList {
|
||
|
|
const result = ranks.reduce((acc, rank) => {
|
||
|
|
if (!acc[rank.player_id]) {
|
||
|
|
acc[rank.player_id] = {}
|
||
|
|
}
|
||
|
|
|
||
|
|
acc[rank.player_id][rank.gamemode] = this.getPlayerRank(rank)
|
||
|
|
return acc
|
||
|
|
}, {} as SerializedPlayerRanksList)
|
||
|
|
|
||
|
|
return result
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
export default new MatchPlayerRankSerializer()
|