mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-05 19:20:12 +08:00
feat: modify analytics
This commit is contained in:
1 parent
61f627b125
commit
3e7092dbd6
3 files changed
+9
-4
No files matched your search
@@ -3,5 +3,8 @@ import { questList } from '../models/quests.js'
|
||||
// eslint-disable-next-line import/prefer-default-export
|
||||
export async function questListController(req, res) {
|
||||
const quests = await questList()
|
||||
quests.forEach((quest) => {
|
||||
quest.failed = quest.started - quest.completed
|
||||
})
|
||||
res.render('quests', { quests })
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/* eslint-disable object-shorthand */
|
||||
/* eslint-disable func-names */
|
||||
import { UserProfile, Quest } from '@linux-odyssey/models'
|
||||
import { UserProfile } from '@linux-odyssey/models'
|
||||
|
||||
export function totalQuests() {
|
||||
return UserProfile.aggregate([
|
||||
@@ -98,7 +98,7 @@ export function questList() {
|
||||
else: {
|
||||
$round: [
|
||||
{ $multiply: [{ $divide: ['$completed', '$started'] }, 100] },
|
||||
2,
|
||||
0,
|
||||
],
|
||||
},
|
||||
},
|
||||
@@ -107,7 +107,7 @@ export function questList() {
|
||||
},
|
||||
{
|
||||
$sort: {
|
||||
_id: 1, // 按任务ID升序排序
|
||||
completed: -1,
|
||||
},
|
||||
},
|
||||
])
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
<th>Id</th>
|
||||
<th>Started</th>
|
||||
<th>Completed</th>
|
||||
<th>Failed</th>
|
||||
<th>Completed Rate</th>
|
||||
</tr>
|
||||
{{#each quests}}
|
||||
@@ -12,7 +13,8 @@
|
||||
<td>{{_id}}</td>
|
||||
<td>{{started}}</td>
|
||||
<td>{{completed}}</td>
|
||||
<td>{{completedRate}}</td>
|
||||
<td>{{failed}}</td>
|
||||
<td>{{completedRate}} %</td>
|
||||
</tr>
|
||||
{{/each}}
|
||||
</table>
|
||||
Reference in new issue
Block a user