mirror of
https://github.com/amineo/t2-stat-parser.git
synced 2026-01-20 01:34:47 +00:00
add some docs
This commit is contained in:
parent
cdbcbe19e3
commit
354ea453e0
|
|
@ -40,6 +40,7 @@ class PlayerController {
|
|||
.where({ player_guid: request.params.player_guid })
|
||||
|
||||
|
||||
// Dynamically generate and sum the stats object
|
||||
let playerStatTotals = {},
|
||||
statKeys = Object.keys(playerStatData[0].stats)
|
||||
|
||||
|
|
@ -50,10 +51,12 @@ class PlayerController {
|
|||
playerStatTotals[statKeys[i]] = 0;
|
||||
}
|
||||
|
||||
|
||||
// Loop through the playerStatsData query from the DB
|
||||
playerStatData.map(statLine => {
|
||||
// look through each object in playerStatsData array
|
||||
for (let [key, value] of Object.entries(statLine.stats)) {
|
||||
// console.log(`${key}: ${value}`);
|
||||
// If the stat item exists, add it -- if not create a new key in playerStatTotals
|
||||
if(playerStatTotals.hasOwnProperty(key) === true){
|
||||
playerStatTotals[key] = playerStatTotals[key] + Number(value);
|
||||
}else{
|
||||
|
|
@ -62,7 +65,6 @@ class PlayerController {
|
|||
}
|
||||
})
|
||||
|
||||
console.log(playerStatTotals);
|
||||
|
||||
let playerData = {
|
||||
player: playerInfo[0],
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ export default function Player(props) {
|
|||
/>
|
||||
|
||||
<div className="bg-white shadow overflow-hidden sm:rounded-md">
|
||||
<div className="py-10 px-10">{JSON.stringify(props.playerData.totals)}</div>
|
||||
<div className="py-10 px-10"><code> {JSON.stringify(props.playerData.stats)}</code></div>
|
||||
</div>
|
||||
</Layout>
|
||||
|
|
|
|||
Loading…
Reference in a new issue