return less data if long time frame
All checks were successful
deploy / deploy (push) Successful in 29s
All checks were successful
deploy / deploy (push) Successful in 29s
This commit is contained in:
parent
fbbf677667
commit
42485166bf
@ -11,7 +11,7 @@ const getPlayerHistoryQuery = `from(bucket: "${INFLUXDB_BUCKET}")
|
|||||||
|> 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")
|
||||||
|> aggregateWindow(every: 1h, fn: mean)
|
|> aggregateWindow(every: {}, fn: mean)
|
||||||
|> yield()
|
|> yield()
|
||||||
`;
|
`;
|
||||||
|
|
||||||
@ -29,9 +29,15 @@ app.get("/analytics", async (req, res) => {
|
|||||||
error: "Time range too large. Max time range is 30 days.",
|
error: "Time range too large. Max time range is 30 days.",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
const shouldUseLongerIntervals = timeInMs > 24 * 60 * 60 * 1000 * 7; // 7 days
|
||||||
|
|
||||||
const rows = await InfluxQueryAPI.collectRows(
|
const rows = await InfluxQueryAPI.collectRows(
|
||||||
formatString(getPlayerHistoryQuery, false, timeQuery)
|
formatString(
|
||||||
|
getPlayerHistoryQuery,
|
||||||
|
false,
|
||||||
|
timeQuery,
|
||||||
|
shouldUseLongerIntervals ? "6h" : "1h"
|
||||||
|
)
|
||||||
);
|
);
|
||||||
let history = rows.map((row: any) => ({
|
let history = rows.map((row: any) => ({
|
||||||
time: row._time,
|
time: row._time,
|
||||||
|
Loading…
Reference in New Issue
Block a user