Compare commits

...

2 Commits

Author SHA1 Message Date
Douglas Barone
be7262bbdf Fix userPresence sorting in Query 2024-01-19 14:35:21 -04:00
Douglas Barone
9829092229 Refactor userPresence query and updateQuery function 2024-01-19 12:08:37 -04:00
2 changed files with 9 additions and 12 deletions

View File

@ -8,9 +8,9 @@ export async function userPresence(_, { search, onlyServants }) {
where: {
wifiDevices: { some: { lastSeen: { not: null } } }
},
orderBy: { displayName: 'asc' },
include: {
wifiDevices: {
orderBy: [{ lastSeen: 'desc' }],
include: { accessPoint: true }
}
}
@ -50,7 +50,7 @@ export async function userPresence(_, { search, onlyServants }) {
}
const sortedUsers = filteredUsers
.sort((a, b) => b.displayName.localeCompare(a.displayName))
.sort((a, b) => a.displayName.localeCompare(b.displayName))
.sort((a, b) => {
const [aStatus, bStatus] = [
a.wifiDevices[0].status,
@ -69,7 +69,7 @@ export async function userPresence(_, { search, onlyServants }) {
)
return 1
return a.wifiDevices[0].lastSeen < b.wifiDevices[0].lastSeen ? 1 : -1
return 0
})
const userPresence = sortedUsers

View File

@ -269,7 +269,6 @@
<script>
import gql from 'graphql-tag'
import Avatar from '@/components/Avatar'
import { debounce } from '../utils/debounce'
export default {
name: 'UserPresence',
@ -363,14 +362,12 @@ export default {
}[status]
},
updateQuery() {
debounce(() =>
this.$router.replace({
query: {
search: this.search || undefined,
onlyServants: this.onlyServants || undefined
}
})
)()
}
}
}