Sort result
This commit is contained in:
parent
53cfbbf7e1
commit
acbe13a0b1
|
@ -92,10 +92,18 @@ const Query = {
|
||||||
},
|
},
|
||||||
|
|
||||||
async wifiUsers() {
|
async wifiUsers() {
|
||||||
return prisma.user.findMany({
|
const wifiUsers = await prisma.user.findMany({
|
||||||
where: { wifiDevices: { some: { id: { not: undefined } } } },
|
where: { wifiDevices: { some: { id: { not: undefined } } } },
|
||||||
include: { wifiDevices: true }
|
include: { wifiDevices: true }
|
||||||
})
|
})
|
||||||
|
|
||||||
|
wifiUsers.sort(
|
||||||
|
(a, b) =>
|
||||||
|
b.wifiDevices.filter(device => device.isOnline).length -
|
||||||
|
a.wifiDevices.filter(device => device.isOnline).length
|
||||||
|
)
|
||||||
|
|
||||||
|
return wifiUsers
|
||||||
},
|
},
|
||||||
|
|
||||||
async userPresence(_, { search }) {
|
async userPresence(_, { search }) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user