From a1c96d9bcb090f1c72a883a9ccfdd85ba977cbbb Mon Sep 17 00:00:00 2001 From: tamaina Date: Mon, 29 May 2023 14:11:51 +0000 Subject: [PATCH] wip --- .../api/endpoints/admin/get-index-stats.ts | 18 +++------------ packages/misskey-js/src/endpoints.ts | 22 ++++++++++++++++++- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/packages/backend/src/server/api/endpoints/admin/get-index-stats.ts b/packages/backend/src/server/api/endpoints/admin/get-index-stats.ts index 8ffd2b01e7..126397dcae 100644 --- a/packages/backend/src/server/api/endpoints/admin/get-index-stats.ts +++ b/packages/backend/src/server/api/endpoints/admin/get-index-stats.ts @@ -3,27 +3,15 @@ import { DataSource } from 'typeorm'; import { Endpoint } from '@/server/api/endpoint-base.js'; import { DI } from '@/di-symbols.js'; -export const meta = { - requireCredential: true, - requireAdmin: true, - - tags: ['admin'], -} as const; - -export const paramDef = { - type: 'object', - properties: {}, - required: [], -} as const; - // eslint-disable-next-line import/no-default-export @Injectable() -export default class extends Endpoint { +export default class extends Endpoint<'admin/get-index-stats'> { + name = 'admin/get-index-stats' as const; constructor( @Inject(DI.db) private db: DataSource, ) { - super(meta, paramDef, async () => { + super(async () => { const stats = await this.db.query('SELECT * FROM pg_indexes;').then(recs => { const res = [] as { tablename: string; indexname: string; }[]; for (const rec of recs) { diff --git a/packages/misskey-js/src/endpoints.ts b/packages/misskey-js/src/endpoints.ts index d1a21d7390..99a87c5815 100644 --- a/packages/misskey-js/src/endpoints.ts +++ b/packages/misskey-js/src/endpoints.ts @@ -1465,7 +1465,27 @@ export const endpoints = { }, res: undefined, }], - } + }, + 'admin/get-index-stats': { + requireCredential: true, + requireAdmin: true, + + tags: ['admin'], + + defines: [{ + req: undefined, + res: { + type: 'array', + items: { + type: 'object', + properties: { + tablename: { type: 'string' }, + indexname: { type: 'string' }, + }, + }, + }, + }], + }, } as const satisfies { [x: string]: IEndpointMeta; }; /**