From 43343d94a953d817b5f1f8450de22e7aeb340773 Mon Sep 17 00:00:00 2001 From: Kinetix Date: Fri, 17 Jan 2025 13:32:46 -0800 Subject: [PATCH 1/2] Restore activeHalfyear and activeMonth nodeinfo With this content being cached by nginx, these queries shouldn't run more than once every 15 minutes (or whatever your content cache is set to), as far as I understand it. I have verified HIT/MISS via the returned HTTP headers. Perhaps this is more of an issue on large instances, but rather than this data just missing for all instances, perhaps a control panel option could be added to enable/disable this? Misskey nulled these stats as part of a performance issue: https://github.com/misskey-dev/misskey/issues/9505 and committed changes at https://github.com/misskey-dev/misskey/commit/c5cfbd99d03c88038becfed9d99df5dbb175e154 --- .../backend/src/server/NodeinfoServerService.ts | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/packages/backend/src/server/NodeinfoServerService.ts b/packages/backend/src/server/NodeinfoServerService.ts index 6dee6ecd78..29d2edd76b 100644 --- a/packages/backend/src/server/NodeinfoServerService.ts +++ b/packages/backend/src/server/NodeinfoServerService.ts @@ -4,7 +4,9 @@ */ import { Inject, Injectable } from '@nestjs/common'; +import { IsNull, MoreThan } from 'typeorm'; import { DI } from '@/di-symbols.js'; +import type { UsersRepository } from '@/models/_.js'; import type { Config } from '@/config.js'; import { MetaService } from '@/core/MetaService.js'; import { MemorySingleCache } from '@/misc/cache.js'; @@ -25,6 +27,9 @@ export class NodeinfoServerService { @Inject(DI.config) private config: Config, + @Inject(DI.usersRepository) + private usersRepository: UsersRepository, + private userEntityService: UserEntityService, private metaService: MetaService, private notesChart: NotesChart, @@ -57,17 +62,17 @@ 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 activeHalfyear = null; + // const activeMonth = null; const proxyAccount = meta.proxyAccountId ? await this.userEntityService.pack(meta.proxyAccountId).catch(() => null) : null; From be075d9c5fc9af00eb54017fc2fb877b1a442024 Mon Sep 17 00:00:00 2001 From: Kinetix Date: Sun, 26 Jan 2025 13:23:14 -0800 Subject: [PATCH 2/2] This seems to function, doesn't include bots --- packages/backend/src/server/NodeinfoServerService.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/packages/backend/src/server/NodeinfoServerService.ts b/packages/backend/src/server/NodeinfoServerService.ts index 29d2edd76b..fe7d463b41 100644 --- a/packages/backend/src/server/NodeinfoServerService.ts +++ b/packages/backend/src/server/NodeinfoServerService.ts @@ -67,13 +67,10 @@ export class NodeinfoServerService { ] = 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(), isBot: false, lastActiveDate: MoreThan(new Date(now - 15552000000)) } }), + this.usersRepository.count({ where: { host: IsNull(), isBot: false, 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 };