diff --git a/server/src/lib/wifiStats.js b/server/src/lib/wifiStats.js new file mode 100644 index 0000000..d7d13f2 --- /dev/null +++ b/server/src/lib/wifiStats.js @@ -0,0 +1,56 @@ +import prisma from "../prisma"; + +generateStatsForAccessPoint(1) + +async function generateStatsForAccessPoint(accessPointId) { + const timestamp = new Date() + + const stats = await prisma.wifiDevice.aggregate({ + where: { + accessPointId, + status: 'ONLINE' + }, + _count: { + _all: true + }, + _avg: { + signalStrength: true, + speed: true, + usage: true + }, + _max: { + signalStrength: true, + speed: true, + usage: true + }, + _min: { + signalStrength: true, + speed: true, + + } + }) + + console.log(timestamp, stats) +} + + // id Int @id @default(autoincrement()) + // timestamp DateTime @default(now()) + + // clients Int? + + // avgSignal Int? + // minSignal Int? + // maxSignal Int? + + // avgSpeed Int? + // minSpeed Int? + // maxSpeed Int? + + // avgClientUptime Int? + // maxClientUptime Int? + + // avgUsage Int? + // sumUsage Int? + + // accessPointId Int + // accessPoint AccessPoint @relation("wifistats_to_ap", fields: [accessPointId], references: [id]) \ No newline at end of file