Add more post processing tasks (points)
This commit is contained in:
parent
11c430276c
commit
882b38439e
|
@ -14,7 +14,7 @@ export default async function postTasks() {
|
||||||
|
|
||||||
log("Loading cached info from DDNet...")
|
log("Loading cached info from DDNet...")
|
||||||
const cache = decodeMsgpack()
|
const cache = decodeMsgpack()
|
||||||
|
/*
|
||||||
log("Adding total amounts of finishes to maps!")
|
log("Adding total amounts of finishes to maps!")
|
||||||
for (const category in cache.maps) {
|
for (const category in cache.maps) {
|
||||||
for (const i in cache.maps[category]) {
|
for (const i in cache.maps[category]) {
|
||||||
|
@ -28,4 +28,59 @@ export default async function postTasks() {
|
||||||
log(`Processed ${category} map ${i}/${cache.maps[category].length} -> «${map[0]}» with ${map[2]} finishes!`)
|
log(`Processed ${category} map ${i}/${cache.maps[category].length} -> «${map[0]}» with ${map[2]} finishes!`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log("Adding points to players")
|
||||||
|
for (const entry of cache.pointsRanks) {
|
||||||
|
const playerFromDB = await Player.findOne({ name: entry[0] })
|
||||||
|
if (!playerFromDB) continue
|
||||||
|
|
||||||
|
playerFromDB.points = entry[1]
|
||||||
|
playerFromDB.save()
|
||||||
|
|
||||||
|
log(`Processed ${entry[1]} points for ${entry[0]}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
log("Adding rank points to players")
|
||||||
|
for (const entry of cache.rankPoints) {
|
||||||
|
const playerFromDB = await Player.findOne({ name: entry[0] })
|
||||||
|
if (!playerFromDB) continue
|
||||||
|
|
||||||
|
playerFromDB.rankPoints = entry[1]
|
||||||
|
playerFromDB.save()
|
||||||
|
|
||||||
|
log(`Processed ${entry[1]} rank points for ${entry[0]}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
log("Adding team points to players")
|
||||||
|
for (const entry of cache.teamRankPoints) {
|
||||||
|
const playerFromDB = await Player.findOne({ name: entry[0] })
|
||||||
|
if (!playerFromDB) continue
|
||||||
|
|
||||||
|
playerFromDB.teamPoints = entry[1]
|
||||||
|
playerFromDB.save()
|
||||||
|
|
||||||
|
log(`Processed ${entry[1]} team points for ${entry[0]}`)
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
log("Adding weekly points to players")
|
||||||
|
for (const entry of cache.pointsThisWeek) {
|
||||||
|
const playerFromDB = await Player.findOne({ name: entry[0] })
|
||||||
|
if (!playerFromDB) continue
|
||||||
|
|
||||||
|
playerFromDB.pointsThisWeek = entry[1]
|
||||||
|
playerFromDB.save()
|
||||||
|
|
||||||
|
log(`Processed ${entry[1]} weekly points for ${entry[0]}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
log("Adding monthly points to players")
|
||||||
|
for (const entry of cache.teamRankPoints) {
|
||||||
|
const playerFromDB = await Player.findOne({ name: entry[0] })
|
||||||
|
if (!playerFromDB) continue
|
||||||
|
|
||||||
|
playerFromDB.pointsThisMonth = entry[1]
|
||||||
|
playerFromDB.save()
|
||||||
|
|
||||||
|
log(`Processed ${entry[1]} team points for ${entry[0]}`)
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -5,6 +5,8 @@ const Player = new mongoose.Schema({
|
||||||
points: Number,
|
points: Number,
|
||||||
rankPoints: Number,
|
rankPoints: Number,
|
||||||
teamPoints: Number,
|
teamPoints: Number,
|
||||||
|
pointsThisWeek: Number,
|
||||||
|
pointsThisMonth: Number,
|
||||||
firstFinish: Date
|
firstFinish: Date
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user