mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-08 11:30:12 +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 { questCount, questCompleted } from '../models/profiles.js'
|
||||
import { totalQuests, totalCompleted } from '../models/profiles.js'
|
||||
|
||||
// eslint-disable-next-line import/prefer-default-export
|
||||
export async function homeController(req, res) {
|
||||
const payload = {
|
||||
title: 'Linux Odyssey Admin',
|
||||
userCount: await userCount(),
|
||||
questCount: await questCount(),
|
||||
questCompleted: await questCompleted(),
|
||||
totalQuests: await totalQuests(),
|
||||
totalCompleted: await totalCompleted(),
|
||||
}
|
||||
payload.completedRate =
|
||||
Math.round((payload.questCompleted / payload.questCount) * 10000) / 100
|
||||
Math.round((payload.totalCompleted / payload.totalQuests) * 10000) / 100
|
||||
res.render('home', payload)
|
||||
}
|
||||
@@ -2,11 +2,11 @@
|
||||
/* eslint-disable func-names */
|
||||
import { UserProfile } from '@linux-odyssey/models'
|
||||
|
||||
export function questCount() {
|
||||
export function totalQuests() {
|
||||
return UserProfile.find().count()
|
||||
}
|
||||
|
||||
export function questCompleted() {
|
||||
export function totalCompleted() {
|
||||
return UserProfile.find({
|
||||
$where: function () {
|
||||
for (const key in this.progress) {
|
||||
@@ -18,3 +18,7 @@ export function questCompleted() {
|
||||
},
|
||||
}).count()
|
||||
}
|
||||
|
||||
export function userProfileList() {
|
||||
return UserProfile.find()
|
||||
}
|
||||
Reference in new issue
Block a user