Metrics Tracking Fix

This commit is contained in:
ssyyhhrr
2022-12-26 18:13:52 +00:00
parent ae6b6044d0
commit 91d7395418
2 changed files with 8 additions and 2 deletions

9
app.js
View File

@@ -83,8 +83,13 @@ schedule.scheduleJob("0 0 * * *", async () => {
throw "Ergast API is unreachable and the drivers.json cache has not been built. Please try again when the Ergast API is online."
}
})
let rawStatsFile = fs.readFileSync(statsPath)
let statsFile = JSON.parse(rawStatsFile)
let statsFile
if (fs.existsSync(statsPath)) {
let rawStatsFile = fs.readFileSync(statsPath)
statsFile = JSON.parse(rawStatsFile)
} else {
statsFile = {}
}
let date = dayjs.format("YYYY-MM-DD")
statsFile[date] = stats
let newStatsFile = JSON.stringify(statsFile)