mirror of
https://github.com/ssyyhhrr/stewardle.git
synced 2025-11-15 21:33:49 -05:00
Changing Drivers Fix
This commit is contained in:
13
app.js
13
app.js
@@ -147,11 +147,10 @@ async function updateDrivers() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function processStats() {
|
function processStats(dotd = false) {
|
||||||
let date = dayjs().format("YYYY-MM-DD")
|
let date = dayjs().format("YYYY-MM-DD")
|
||||||
let statsFile = {}
|
|
||||||
if (fs.existsSync(statsPath)) {
|
if (fs.existsSync(statsPath)) {
|
||||||
statsFile = JSON.parse(fs.readFileSync(statsPath))
|
let statsFile = JSON.parse(fs.readFileSync(statsPath))
|
||||||
if (statsFile.hasOwnProperty(date)) {
|
if (statsFile.hasOwnProperty(date)) {
|
||||||
if (statsFile[date]["visits"] < stats["visits"]) {
|
if (statsFile[date]["visits"] < stats["visits"]) {
|
||||||
statsFile[date]["visits"] = stats["visits"]
|
statsFile[date]["visits"] = stats["visits"]
|
||||||
@@ -168,13 +167,11 @@ function processStats() {
|
|||||||
if (!statsFile[date].hasOwnProperty("driver") && stats.hasOwnProperty("driver")) {
|
if (!statsFile[date].hasOwnProperty("driver") && stats.hasOwnProperty("driver")) {
|
||||||
statsFile[date]["driver"] = stats["driver"]
|
statsFile[date]["driver"] = stats["driver"]
|
||||||
}
|
}
|
||||||
} else {
|
} else if (dotd) {
|
||||||
statsFile[date] = stats
|
statsFile[date] = stats
|
||||||
}
|
}
|
||||||
} else {
|
fs.writeFileSync(statsPath, JSON.stringify(statsFile))
|
||||||
statsFile[date] = stats
|
|
||||||
}
|
}
|
||||||
fs.writeFileSync(statsPath, JSON.stringify(statsFile))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function dotd() {
|
function dotd() {
|
||||||
@@ -201,7 +198,7 @@ function dotd() {
|
|||||||
"guesses": 0,
|
"guesses": 0,
|
||||||
"driver": driver
|
"driver": driver
|
||||||
}
|
}
|
||||||
processStats()
|
processStats(true)
|
||||||
console.log(`Driver of the Day is ${driver}!`)
|
console.log(`Driver of the Day is ${driver}!`)
|
||||||
console.log(drivers[driver])
|
console.log(drivers[driver])
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user