From e2cefb7f476bfa46844a9ee027af523e9e01f21d Mon Sep 17 00:00:00 2001 From: xianon Date: Sat, 22 Jan 2022 02:13:29 +0900 Subject: [PATCH] =?UTF-8?q?NodeInfo=20=E3=81=AB=E3=83=A6=E3=83=BC=E3=82=B6?= =?UTF-8?q?=E3=83=BC=E6=95=B0=E3=81=A8=E6=8A=95=E7=A8=BF=E6=95=B0=E3=81=AE?= =?UTF-8?q?=E6=83=85=E5=A0=B1=E3=82=92=E8=BF=BD=E5=8A=A0=E3=81=99=E3=82=8B?= =?UTF-8?q?=20(#8126)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/backend/src/server/nodeinfo.ts | 32 ++++++++++++------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/packages/backend/src/server/nodeinfo.ts b/packages/backend/src/server/nodeinfo.ts index 097c6c664..44f32bf88 100644 --- a/packages/backend/src/server/nodeinfo.ts +++ b/packages/backend/src/server/nodeinfo.ts @@ -1,9 +1,8 @@ import * as Router from '@koa/router'; import config from '@/config/index'; import { fetchMeta } from '@/misc/fetch-meta'; -import { Users } from '@/models/index'; -// import User from '../models/user'; -// import Note from '../models/note'; +import { Users, Notes } from '@/models/index'; +import { Not, IsNull, MoreThan } from 'typeorm'; const router = new Router(); @@ -19,20 +18,21 @@ export const links = [/* (awaiting release) { }]; const nodeinfo2 = async () => { + const now = Date.now(); const [ meta, - // total, - // activeHalfyear, - // activeMonth, - // localPosts, - // localComments + total, + activeHalfyear, + activeMonth, + localPosts, + localComments, ] = await Promise.all([ fetchMeta(true), - // User.count({ host: null }), - // User.count({ host: null, updatedAt: { $gt: new Date(Date.now() - 15552000000) } }), - // User.count({ host: null, updatedAt: { $gt: new Date(Date.now() - 2592000000) } }), - // Note.count({ '_user.host': null, replyId: null }), - // Note.count({ '_user.host': null, replyId: { $ne: null } }) + Users.count({ where: { host: null } }), + Users.count({ where: { host: null, updatedAt: MoreThan(new Date(now - 15552000000)) } }), + Users.count({ where: { host: null, updatedAt: MoreThan(new Date(now - 2592000000)) } }), + Notes.count({ where: { userHost: null, replyId: null } }), + Notes.count({ where: { userHost: null, replyId: Not(IsNull()) } }), ]); const proxyAccount = meta.proxyAccountId ? await Users.pack(meta.proxyAccountId).catch(() => null) : null; @@ -50,9 +50,9 @@ const nodeinfo2 = async () => { }, openRegistrations: !meta.disableRegistration, usage: { - users: {}, // { total, activeHalfyear, activeMonth }, - // localPosts, - // localComments + users: { total, activeHalfyear, activeMonth }, + localPosts, + localComments, }, metadata: { nodeName: meta.name,