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

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