From befe91351722a320a106c7cd396b0192b1963dd9 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 8 May 2021 12:51:23 +0900 Subject: [PATCH] Create get-index-stats.ts --- .../api/endpoints/admin/get-index-stats.ts | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/server/api/endpoints/admin/get-index-stats.ts diff --git a/src/server/api/endpoints/admin/get-index-stats.ts b/src/server/api/endpoints/admin/get-index-stats.ts new file mode 100644 index 000000000..f2b06d0ef --- /dev/null +++ b/src/server/api/endpoints/admin/get-index-stats.ts @@ -0,0 +1,26 @@ +import define from '../../define'; +import { getConnection } from 'typeorm'; + +export const meta = { + requireCredential: true as const, + requireModerator: true, + + tags: ['admin'], + + params: { + }, +}; + +export default define(meta, async () => { + const stats = await + getConnection().query(`SELECT * FROM pg_indexes;`) + .then(recs => { + const res = [] as { tablename: string; indexname: string; }[]; + for (const rec of recs) { + res.push(rec); + } + return res; + }); + + return stats; +});