diff --git a/CHANGELOG.md b/CHANGELOG.md index 8ccb2cd94d181708bde47b7a4495ad7bd009ba22..d2b5ffde3af45a8dc6fe3665bd629dfa394e2d68 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -63,6 +63,7 @@ You should also include the user name that made the change. - Server: improve note scoring for featured notes @CyberRex0 - Server: アンケートé¸æŠžè‚¢ã®æ–‡å—数制é™ã‚’ç·©å’Œ @syuilo - Server: improve stats api performance @syuilo +- Server: improve nodeinfo performance @syuilo - Server: delete outdated notifications regularly to improve db performance @syuilo - Server: delete outdated hard-mutes regularly to improve db performance @syuilo - Server: delete outdated notes of antenna regularly to improve db performance @syuilo diff --git a/packages/backend/src/server/NodeinfoServerService.ts b/packages/backend/src/server/NodeinfoServerService.ts index 86d87872b2e0aea0dd095e0221584a872a8e7352..c4236c8752bc1834d15b9b1e955c92a31b099540 100644 --- a/packages/backend/src/server/NodeinfoServerService.ts +++ b/packages/backend/src/server/NodeinfoServerService.ts @@ -8,6 +8,8 @@ import { MAX_NOTE_TEXT_LENGTH } from '@/const.js'; import { Cache } from '@/misc/cache.js'; import { UserEntityService } from '@/core/entities/UserEntityService.js'; import { bindThis } from '@/decorators.js'; +import NotesChart from '@/core/chart/charts/notes.js'; +import UsersChart from '@/core/chart/charts/users.js'; import type { FastifyInstance, FastifyPluginOptions } from 'fastify'; const nodeinfo2_1path = '/nodeinfo/2.1'; @@ -27,6 +29,8 @@ export class NodeinfoServerService { private userEntityService: UserEntityService, private metaService: MetaService, + private notesChart: NotesChart, + private usersChart: UsersChart, ) { //this.createServer = this.createServer.bind(this); } @@ -46,20 +50,27 @@ export class NodeinfoServerService { public createServer(fastify: FastifyInstance, options: FastifyPluginOptions, done: (err?: Error) => void) { const nodeinfo2 = async () => { const now = Date.now(); + + const notesChart = await this.notesChart.getChart('hour', 1, null); + const localPosts = notesChart.local.total[0]; + + const usersChart = await this.usersChart.getChart('hour', 1, null); + const total = usersChart.local.total[0]; + const [ meta, - total, - activeHalfyear, - activeMonth, - localPosts, + //activeHalfyear, + //activeMonth, ] = await Promise.all([ this.metaService.fetch(true), - this.usersRepository.count({ where: { host: IsNull() } }), - 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() } }), + // é‡ã„ + //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; return {