fix crash when some match stats are empty
This commit is contained in:
+14
-7
@@ -91,7 +91,6 @@ router.post(
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
const playerData = req.body[playerId]
|
const playerData = req.body[playerId]
|
||||||
console.log(req.body)
|
|
||||||
|
|
||||||
const promises: Array<Promise<any>> = []
|
const promises: Array<Promise<any>> = []
|
||||||
const weaponStats: WeaponStatsInMatchTable[] = []
|
const weaponStats: WeaponStatsInMatchTable[] = []
|
||||||
@@ -131,15 +130,19 @@ router.post(
|
|||||||
}
|
}
|
||||||
|
|
||||||
playerPromises.push(Promise.all(promises).then(async e => {
|
playerPromises.push(Promise.all(promises).then(async e => {
|
||||||
await db.insertInto('ToneAPI_v3.weapon_stats_in_match')
|
if (weaponStats.length > 0) {
|
||||||
.values(weaponStats)
|
await db.insertInto('ToneAPI_v3.weapon_stats_in_match')
|
||||||
.execute()
|
.values(weaponStats)
|
||||||
|
.execute()
|
||||||
|
}
|
||||||
}))
|
}))
|
||||||
|
|
||||||
playerPromises.push(Promise.all(promises).then(async e => {
|
playerPromises.push(Promise.all(promises).then(async e => {
|
||||||
await db.insertInto('ToneAPI_v3.titan_stats_in_match')
|
if (titanStats.length > 0) {
|
||||||
.values(titanStats)
|
await db.insertInto('ToneAPI_v3.titan_stats_in_match')
|
||||||
.execute()
|
.values(titanStats)
|
||||||
|
.execute()
|
||||||
|
}
|
||||||
}))
|
}))
|
||||||
|
|
||||||
playerPromises.push(db.insertInto('ToneAPI_v3.player_stats_in_match')
|
playerPromises.push(db.insertInto('ToneAPI_v3.player_stats_in_match')
|
||||||
@@ -156,6 +159,10 @@ router.post(
|
|||||||
.execute())
|
.execute())
|
||||||
}
|
}
|
||||||
await Promise.all(playerPromises)
|
await Promise.all(playerPromises)
|
||||||
|
await db.updateTable('ToneAPI_v3.match')
|
||||||
|
.set({ ongoing: false })
|
||||||
|
.where('match_id', '=', match_id)
|
||||||
|
.execute()
|
||||||
res.sendStatus(201)
|
res.sendStatus(201)
|
||||||
})()
|
})()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user