From 305818be23003f8a53794c6c5f4630cedd3de41d Mon Sep 17 00:00:00 2001 From: Valentin Kaelin Date: Sun, 12 Jan 2020 01:35:36 +0100 Subject: [PATCH] fix: forgot to push helper method for creating records --- client/src/helpers/summoner.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/client/src/helpers/summoner.js b/client/src/helpers/summoner.js index a09a945..666408a 100644 --- a/client/src/helpers/summoner.js +++ b/client/src/helpers/summoner.js @@ -58,6 +58,24 @@ export function createBasicSummonerData(RiotData) { return RiotData } +/** + * Return the formatted records of a summoner + * @param {Object} records : raw records from the database stats + */ +export function createRecordsData(records) { + const min = Math.floor(records.maxTime.time / 60) + let newSec = Math.floor(records.maxTime.time - min * 60) + newSec = newSec < 10 ? '0' + newSec : newSec + records.maxTime.time = `${min}:${newSec}` + records.maxGold.gold = records.maxGold.gold.toLocaleString() + records.maxDmgTaken.dmgTaken = records.maxDmgTaken.dmgTaken.toLocaleString() + records.maxDmgChamp.dmgChamp = records.maxDmgChamp.dmgChamp.toLocaleString() + records.maxDmgObj.dmgObj = records.maxDmgObj.dmgObj.toLocaleString() + records.maxKp.kp = `${records.maxKp.kp}%` + + return records +} + function getLeagueData(leagueData, leagueName) { if (!leagueData) return null