feat: add error commands page

This commit is contained in:
wancat committed 2023-10-14 17:43:12 +08:00
1 parent d249207283
commit 50e53b5667
6 files changed
+60 -1

No files matched your search

+26
View File
@@ -0,0 +1,26 @@
import { Command } from '@linux-odyssey/models'
// eslint-disable-next-line import/prefer-default-export
export async function errorCommands() {
const commands = await Command.find({ error: { $ne: '' } })
.populate({
path: 'session',
populate: [
{
path: 'user',
},
{ path: 'quest' },
],
})
.exec()
return commands.map(({ command, error, createdAt, session }) => {
const { user, quest } = session
return {
command,
error,
createdAt: createdAt.toLocaleString(),
user: user.username,
quest: quest.id,
}
})
}