diff --git a/server/src/resolvers/AccessPoint.js b/server/src/resolvers/AccessPoint.js index d86c617..c57632a 100644 --- a/server/src/resolvers/AccessPoint.js +++ b/server/src/resolvers/AccessPoint.js @@ -1,6 +1,6 @@ import prisma from '../prisma' import { getSubnetInfo } from '../lib/subnetInfo' -import { subDays } from 'date-fns' +import { subDays, subMinutes } from 'date-fns' import { distributedCopy } from '../utils/distributedCopy' export const AccessPoint = { @@ -23,11 +23,8 @@ export const AccessPoint = { usage: (parent, data, context, info) => parent.usage ? parent.usage?.toString() : 0, - stats: async (parent, { take, dateIn, dateOut }, context, info) => { - if (!dateOut) { - dateOut = new Date() - dateIn = subDays(dateOut, 1) - } + stats: async (parent, { take, minutesIn = 60, dateOut }, context, info) => { + const dateIn = subMinutes(dateOut || Date.now(), minutesIn) const stats = await prisma.accessPointStats.findMany({ where: { diff --git a/server/src/typeDefs.js b/server/src/typeDefs.js index ccb5590..9397a48 100644 --- a/server/src/typeDefs.js +++ b/server/src/typeDefs.js @@ -328,7 +328,11 @@ const typeDefs = gql` updatedAt: String wifiDevices: [WifiDevice] - stats(take: Int = 50, dateIn: String, dateOut: String): [AccessPointStats!]! + stats( + take: Int = 128 + minutesIn: Int = 1440 + dateOut: String + ): [AccessPointStats!]! latestStats: AccessPointStats! } diff --git a/web/src/components/Charts/AccessPointClientsChart.vue b/web/src/components/Charts/AccessPointClientsChart.vue index 4974461..95e093c 100644 --- a/web/src/components/Charts/AccessPointClientsChart.vue +++ b/web/src/components/Charts/AccessPointClientsChart.vue @@ -95,13 +95,13 @@ export default { ticks: { maxRotation: 0, minRotation: 0, - autoSkipPadding: 16 + autoSkipPadding: 24 }, time: { unit: 'minute', displayFormats: { - minute: 'HH:mm' + minute: 'd/M HH:mm' } }, @@ -116,7 +116,7 @@ export default { chartData() { const pointRadius = 0 - const tension = 0.2 + const tension = 0.1 return { labels: this.stats.map(stat => new Date(stat.timestamp).getTime()),