add some docs

This commit is contained in:
Anthony Mineo 2020-04-01 20:15:45 -04:00
parent cdbcbe19e3
commit 354ea453e0
2 changed files with 23 additions and 20 deletions

View file

@ -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],

View file

@ -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>