From 7a106a390df979dfbda823af0c52c7729547663b Mon Sep 17 00:00:00 2001 From: eternal-flame-AD Date: Sun, 10 Nov 2024 14:41:40 -0600 Subject: [PATCH] add localComments count Signed-off-by: eternal-flame-AD --- packages/backend/src/server/NodeinfoServerService.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/backend/src/server/NodeinfoServerService.ts b/packages/backend/src/server/NodeinfoServerService.ts index ab073c270f..126df4650c 100644 --- a/packages/backend/src/server/NodeinfoServerService.ts +++ b/packages/backend/src/server/NodeinfoServerService.ts @@ -15,8 +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'; +import { IsNull, MoreThan, Not } from 'typeorm'; +import type { NotesRepository, UsersRepository } from '@/models/_.js'; const nodeinfo2_1path = '/nodeinfo/2.1'; const nodeinfo2_0path = '/nodeinfo/2.0'; @@ -29,6 +29,8 @@ export class NodeinfoServerService { private config: Config, @Inject(DI.usersRepository) private usersRepository: UsersRepository, + @Inject(DI.notesRepository) + private notesRepository: NotesRepository, private userEntityService: UserEntityService, private metaService: MetaService, @@ -64,10 +66,12 @@ export class NodeinfoServerService { meta, activeHalfyear, activeMonth, + localComments, ] = 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.notesRepository.count({ where: { userHost: IsNull(), replyId: Not(IsNull()) } }), ]); const proxyAccount = meta.proxyAccountId ? await this.userEntityService.pack(meta.proxyAccountId).catch(() => null) : null; @@ -91,7 +95,7 @@ export class NodeinfoServerService { usage: { users: { total, activeHalfyear, activeMonth }, localPosts, - localComments: 0, + localComments, }, metadata: { nodeName: meta.name,