fix bug
All checks were successful
deploy / deploy (push) Successful in 29s

This commit is contained in:
Lee 2023-10-27 16:21:32 +01:00
parent 63662a6074
commit e09ee235bc

View File

@ -8,7 +8,7 @@ const port = process.env.PORT || 3000;
// Query to get the player count history for tge last 24 hours in 1 hour intervals
const getPlayerHistoryQuery = `from(bucket: "${INFLUXDB_BUCKET}")
|> range(start: {})
|> range(start: -{})
|> filter(fn: (r) => r["_measurement"] == "scoresaber")
|> filter(fn: (r) => r["_field"] == "value")
|> filter(fn: (r) => r["type"] == "player_count")
@ -32,14 +32,14 @@ app.get("/analytics", async (req, res) => {
}
const shouldUseLongerIntervals = timeInMs > 24 * 60 * 60 * 1000 * 7; // 7 days
const rows = await InfluxQueryAPI.collectRows(
formatString(
getPlayerHistoryQuery,
false,
timeQuery,
shouldUseLongerIntervals ? "6h" : "1h"
)
const query = formatString(
getPlayerHistoryQuery,
false,
timeQuery,
shouldUseLongerIntervals ? "6h" : "1h"
);
console.log(query);
const rows = await InfluxQueryAPI.collectRows(query);
let history = rows.map((row: any) => ({
time: row._time,
value: row._value !== null ? row._value.toFixed(0) : null,