diff --git a/src/index.ts b/src/index.ts index 65232dd..89dde27 100644 --- a/src/index.ts +++ b/src/index.ts @@ -22,5 +22,5 @@ export const InfluxWriteAPI = influxClient.getWriteApi( ); export const InfluxQueryAPI = influxClient.getQueryApi(INFLUXDB_ORG); -require("./updateData"); -require("./api"); +require("./services/updateData"); +require("./services/api"); diff --git a/src/services/api.ts b/src/services/api.ts index dfd4e9f..d6b8279 100644 --- a/src/services/api.ts +++ b/src/services/api.ts @@ -23,15 +23,15 @@ app.get("/analytics", async (req, res) => { const rows = await InfluxQueryAPI.collectRows(getPlayerHistoryQuery); let history = rows.map((row: any) => ({ time: row._time, - value: row._value.toFixed(0), + value: row._value !== null ? row._value.toFixed(0) : null, })); history = history.sort( (a: any, b: any) => new Date(a.time).getTime() - new Date(b.time).getTime() ); return res.json({ + serverTimeTaken: new Date().getTime() - before + "ms", history: history, - serverTimeTaken: new Date().getTime() - before, }); });