This commit is contained in:
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
|
||||
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(
|
||||
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,
|
||||
|
Loading…
Reference in New Issue
Block a user