mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-07 19:10: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
|
// eslint-disable-next-line import/prefer-default-export
|
||||||
export async function questListController(req, res) {
|
export async function questListController(req, res) {
|
||||||
const quests = await questList()
|
const quests = await questList()
|
||||||
|
quests.forEach((quest) => {
|
||||||
|
quest.failed = quest.started - quest.completed
|
||||||
|
})
|
||||||
res.render('quests', { quests })
|
res.render('quests', { quests })
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
/* eslint-disable object-shorthand */
|
/* eslint-disable object-shorthand */
|
||||||
/* eslint-disable func-names */
|
/* eslint-disable func-names */
|
||||||
import { UserProfile, Quest } from '@linux-odyssey/models'
|
import { UserProfile } from '@linux-odyssey/models'
|
||||||
|
|
||||||
export function totalQuests() {
|
export function totalQuests() {
|
||||||
return UserProfile.aggregate([
|
return UserProfile.aggregate([
|
||||||
@@ -98,7 +98,7 @@ export function questList() {
|
|||||||
else: {
|
else: {
|
||||||
$round: [
|
$round: [
|
||||||
{ $multiply: [{ $divide: ['$completed', '$started'] }, 100] },
|
{ $multiply: [{ $divide: ['$completed', '$started'] }, 100] },
|
||||||
2,
|
0,
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -107,7 +107,7 @@ export function questList() {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
$sort: {
|
$sort: {
|
||||||
_id: 1, // 按任务ID升序排序
|
completed: -1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
])
|
])
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
<th>Id</th>
|
<th>Id</th>
|
||||||
<th>Started</th>
|
<th>Started</th>
|
||||||
<th>Completed</th>
|
<th>Completed</th>
|
||||||
|
<th>Failed</th>
|
||||||
<th>Completed Rate</th>
|
<th>Completed Rate</th>
|
||||||
</tr>
|
</tr>
|
||||||
{{#each quests}}
|
{{#each quests}}
|
||||||
@@ -12,7 +13,8 @@
|
|||||||
<td>{{_id}}</td>
|
<td>{{_id}}</td>
|
||||||
<td>{{started}}</td>
|
<td>{{started}}</td>
|
||||||
<td>{{completed}}</td>
|
<td>{{completed}}</td>
|
||||||
<td>{{completedRate}}</td>
|
<td>{{failed}}</td>
|
||||||
|
<td>{{completedRate}} %</td>
|
||||||
</tr>
|
</tr>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</table>
|
</table>
|
||||||
Reference in new issue
Block a user