mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-08 19:40:11 +08:00
fix: analytics modify
This commit is contained in:
1 parent
c243e29002
commit
9200336b49
5 files changed
+20
-16
No files matched your search
@@ -1,15 +1,15 @@
|
|||||||
import { userCount } from '../models/users.js'
|
import { userCount } from '../models/users.js'
|
||||||
import { questCount, questCompleted } from '../models/profiles.js'
|
import { totalQuests, totalCompleted } from '../models/profiles.js'
|
||||||
|
|
||||||
// eslint-disable-next-line import/prefer-default-export
|
// eslint-disable-next-line import/prefer-default-export
|
||||||
export async function homeController(req, res) {
|
export async function homeController(req, res) {
|
||||||
const payload = {
|
const payload = {
|
||||||
title: 'Linux Odyssey Admin',
|
title: 'Linux Odyssey Admin',
|
||||||
userCount: await userCount(),
|
userCount: await userCount(),
|
||||||
questCount: await questCount(),
|
totalQuests: await totalQuests(),
|
||||||
questCompleted: await questCompleted(),
|
totalCompleted: await totalCompleted(),
|
||||||
}
|
}
|
||||||
payload.completedRate =
|
payload.completedRate =
|
||||||
Math.round((payload.questCompleted / payload.questCount) * 10000) / 100
|
Math.round((payload.totalCompleted / payload.totalQuests) * 10000) / 100
|
||||||
res.render('home', payload)
|
res.render('home', payload)
|
||||||
}
|
}
|
||||||
@@ -2,11 +2,11 @@
|
|||||||
/* eslint-disable func-names */
|
/* eslint-disable func-names */
|
||||||
import { UserProfile } from '@linux-odyssey/models'
|
import { UserProfile } from '@linux-odyssey/models'
|
||||||
|
|
||||||
export function questCount() {
|
export function totalQuests() {
|
||||||
return UserProfile.find().count()
|
return UserProfile.find().count()
|
||||||
}
|
}
|
||||||
|
|
||||||
export function questCompleted() {
|
export function totalCompleted() {
|
||||||
return UserProfile.find({
|
return UserProfile.find({
|
||||||
$where: function () {
|
$where: function () {
|
||||||
for (const key in this.progress) {
|
for (const key in this.progress) {
|
||||||
@@ -18,3 +18,7 @@ export function questCompleted() {
|
|||||||
},
|
},
|
||||||
}).count()
|
}).count()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function userProfileList() {
|
||||||
|
return UserProfile.find()
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
<h1>Welcome to {{title}}</h1>
|
<h1>Welcome to {{title}}</h1>
|
||||||
<div>
|
<div>
|
||||||
<h2>Users</h2>
|
<h2>Overview</h2>
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Registered Users</th>
|
<th>Registered Users</th>
|
||||||
@@ -8,11 +8,11 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Total Started Quests</th>
|
<th>Total Started Quests</th>
|
||||||
<td>{{questCount}}</td>
|
<td>{{totalQuests}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Completed Quests</th>
|
<th>Completed Quests</th>
|
||||||
<td>{{questCompleted}}</td>
|
<td>{{totalCompleted}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Completed Rate</th>
|
<th>Completed Rate</th>
|
||||||
|
|||||||
@@ -36,20 +36,20 @@
|
|||||||
|
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Command</th>
|
<th>Stage</th>
|
||||||
<th>PWD</th>
|
<th>PWD</th>
|
||||||
|
<th>Input</th>
|
||||||
<th>Output</th>
|
<th>Output</th>
|
||||||
<th>Error</th>
|
<th>Error</th>
|
||||||
<th>Stage</th>
|
<th>Input Time</th>
|
||||||
<th>Created At</th>
|
|
||||||
</tr>
|
</tr>
|
||||||
{{#each commands}}
|
{{#each commands}}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{command}}</td>
|
<td>{{stage}}</td>
|
||||||
<td>{{pwd}}</td>
|
<td>{{pwd}}</td>
|
||||||
|
<td>{{command}}</td>
|
||||||
<td>{{output}}</td>
|
<td>{{output}}</td>
|
||||||
<td>{{error}}</td>
|
<td>{{error}}</td>
|
||||||
<td>{{stage}}</td>
|
|
||||||
<td>{{createdAt}}</td>
|
<td>{{createdAt}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
|
|||||||
@@ -4,23 +4,23 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<th>User</th>
|
<th>User</th>
|
||||||
<th>Quest</th>
|
<th>Quest</th>
|
||||||
<th></th>
|
|
||||||
<th>Status</th>
|
<th>Status</th>
|
||||||
<th>Created At</th>
|
<th>Created At</th>
|
||||||
<th>Finished At</th>
|
<th>Finished At</th>
|
||||||
<th>Used Time</th>
|
<th>Used Time</th>
|
||||||
<th>Command Count</th>
|
<th>Command Count</th>
|
||||||
|
<th>Session</th>
|
||||||
</tr>
|
</tr>
|
||||||
{{#each sessions}}
|
{{#each sessions}}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{user}}</td>
|
<td>{{user}}</td>
|
||||||
<td>{{quest}}</td>
|
<td>{{quest}}</td>
|
||||||
<td><a href='/sessions/{{_id}}'>Detail</a></td>
|
|
||||||
<td>{{status}}</td>
|
<td>{{status}}</td>
|
||||||
<td>{{createdAt}}</td>
|
<td>{{createdAt}}</td>
|
||||||
<td>{{finishedAt}}</td>
|
<td>{{finishedAt}}</td>
|
||||||
<td>{{usedTime}}</td>
|
<td>{{usedTime}}</td>
|
||||||
<td>{{commandCount}}</td>
|
<td>{{commandCount}}</td>
|
||||||
|
<td><a href='/sessions/{{_id}}'>Detail</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
Reference in new issue
Block a user