From 18a27e3c47051f769e16cc5016b5e56b70e141b5 Mon Sep 17 00:00:00 2001 From: eternal-flame-AD Date: Sun, 10 Nov 2024 02:40:32 -0600 Subject: [PATCH] restore activeHalfYear and activeMonth Signed-off-by: eternal-flame-AD --- .../backend/src/server/NodeinfoServerService.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/backend/src/server/NodeinfoServerService.ts b/packages/backend/src/server/NodeinfoServerService.ts index 740d6b6a58..ab073c270f 100644 --- a/packages/backend/src/server/NodeinfoServerService.ts +++ b/packages/backend/src/server/NodeinfoServerService.ts @@ -15,6 +15,8 @@ import NotesChart from '@/core/chart/charts/notes.js'; import UsersChart from '@/core/chart/charts/users.js'; import { DEFAULT_POLICIES } from '@/core/RoleService.js'; import type { FastifyInstance, FastifyPluginOptions } from 'fastify'; +import { IsNull, MoreThan } from 'typeorm'; +import type { UsersRepository } from '@/models/_.js'; const nodeinfo2_1path = '/nodeinfo/2.1'; const nodeinfo2_0path = '/nodeinfo/2.0'; @@ -25,6 +27,8 @@ export class NodeinfoServerService { constructor( @Inject(DI.config) private config: Config, + @Inject(DI.usersRepository) + private usersRepository: UsersRepository, private userEntityService: UserEntityService, private metaService: MetaService, @@ -58,18 +62,14 @@ export class NodeinfoServerService { const [ meta, - //activeHalfyear, - //activeMonth, + activeHalfyear, + activeMonth, ] = await Promise.all([ this.metaService.fetch(true), - // 重い - //this.usersRepository.count({ where: { host: IsNull(), lastActiveDate: MoreThan(new Date(now - 15552000000)) } }), - //this.usersRepository.count({ where: { host: IsNull(), lastActiveDate: MoreThan(new Date(now - 2592000000)) } }), + this.usersRepository.count({ where: { host: IsNull(), lastActiveDate: MoreThan(new Date(now - 15552000000)) } }), + this.usersRepository.count({ where: { host: IsNull(), lastActiveDate: MoreThan(new Date(now - 2592000000)) } }), ]); - const activeHalfyear = null; - const activeMonth = null; - const proxyAccount = meta.proxyAccountId ? await this.userEntityService.pack(meta.proxyAccountId).catch(() => null) : null; const basePolicies = { ...DEFAULT_POLICIES, ...meta.policies };