Add server stats to fe

This commit is contained in:
iamBadgers committed 2024-05-19 14:44:53 -07:00
1 parent 687f6b941a
commit f14fd0d449
2 files changed
+67 -39

No files matched your search

+13 -6
View File
@@ -15,12 +15,19 @@ app.get('/', (req, res) => {
})
app.post('/api/serverstats/gamestats', jsonParser, async (req, res) => {
let startSeconds = 0
let endSeconds = Number.MAX_SAFE_INTEGER
const month = req.body.monthId % 12
const year = Math.floor(req.body.monthId / 12) + 2023
if (req.body.monthId != -1) {
const month = req.body.monthId % 12
const year = Math.floor(req.body.monthId / 12) + 2023
const startDate = new Date(year, month, 1)
const endDate = new Date(year, month + 1, -1)
const startDate = new Date(year, month, 1)
const endDate = new Date(year, month + 1, -1)
startSeconds = startDate.getTime() / 1000
endSeconds = endDate.getTime() / 1000
}
const serverGameStats = await database.query(
'SELECT ' +
@@ -34,8 +41,8 @@ app.post('/api/serverstats/gamestats', jsonParser, async (req, res) => {
{
type: QueryTypes.SELECT,
replacements: {
startSeconds: startDate.getTime() / 1000,
endSeconds: endDate.getTime() / 1000
startSeconds,
endSeconds
}
}
)