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,