mirror of
https://github.com/ssyyhhrr/stewardle.git
synced 2025-11-12 03:53:47 -05:00
stats.json Fix
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,5 +1,4 @@
|
|||||||
node_modules
|
node_modules
|
||||||
driver.txt
|
driver.txt
|
||||||
drivers.json
|
drivers.json
|
||||||
stats.json
|
|
||||||
.idea
|
.idea
|
||||||
17
app.js
17
app.js
@@ -83,13 +83,8 @@ 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."
|
throw "Ergast API is unreachable and the drivers.json cache has not been built. Please try again when the Ergast API is online."
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
let statsFile
|
let rawStatsFile = fs.readFileSync(statsPath)
|
||||||
if (fs.existsSync(statsPath)) {
|
let statsFile = JSON.parse(rawStatsFile)
|
||||||
let rawStatsFile = fs.readFileSync(statsPath)
|
|
||||||
statsFile = JSON.parse(rawStatsFile)
|
|
||||||
} else {
|
|
||||||
statsFile = {}
|
|
||||||
}
|
|
||||||
let date = dayjs.format("YYYY-MM-DD")
|
let date = dayjs.format("YYYY-MM-DD")
|
||||||
statsFile[date] = stats
|
statsFile[date] = stats
|
||||||
let newStatsFile = JSON.stringify(statsFile)
|
let newStatsFile = JSON.stringify(statsFile)
|
||||||
@@ -196,12 +191,8 @@ function server() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
app.get("/stats", (req, res) => {
|
app.get("/stats", (req, res) => {
|
||||||
if (fs.existsSync(statsPath)) {
|
let rawStatsFile = fs.readFileSync(statsPath)
|
||||||
let rawStatsFile = fs.readFileSync(statsPath)
|
res.json(JSON.parse(rawStatsFile))
|
||||||
res.json(JSON.parse(rawStatsFile))
|
|
||||||
} else {
|
|
||||||
res.json(stats)
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
app.get("/winner", (req, res) => {
|
app.get("/winner", (req, res) => {
|
||||||
|
|||||||
1
assets/stats.json
Normal file
1
assets/stats.json
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{}
|
||||||
Reference in New Issue
Block a user