From e09ee235bc03a7eab265f1c903c8f1b672213f81 Mon Sep 17 00:00:00 2001 From: Liam Date: Fri, 27 Oct 2023 16:21:32 +0100 Subject: [PATCH] fix bug --- src/services/api.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/services/api.ts b/src/services/api.ts index ef0e4f9..c147645 100644 --- a/src/services/api.ts +++ b/src/services/api.ts @@ -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,