diff --git a/packages/backend/src/server/api/endpoints/charts/user/notes.ts b/packages/backend/src/server/api/endpoints/charts/user/notes.ts index 0517b3283..6a818726e 100644 --- a/packages/backend/src/server/api/endpoints/charts/user/notes.ts +++ b/packages/backend/src/server/api/endpoints/charts/user/notes.ts @@ -1,36 +1,15 @@ import { Injectable } from '@nestjs/common'; -import { getJsonSchema } from '@/core/chart/core.js'; import { Endpoint } from '@/server/api/endpoint-base.js'; import PerUserNotesChart from '@/core/chart/charts/per-user-notes.js'; -import { schema } from '@/core/chart/charts/entities/per-user-notes.js'; - -export const meta = { - tags: ['charts', 'users', 'notes'], - - res: getJsonSchema(schema), - - allowGet: true, - cacheSec: 60 * 60, -} as const; - -export const paramDef = { - type: 'object', - properties: { - span: { type: 'string', enum: ['day', 'hour'] }, - limit: { type: 'integer', minimum: 1, maximum: 500, default: 30 }, - offset: { type: 'integer', nullable: true, default: null }, - userId: { type: 'string', format: 'misskey:id' }, - }, - required: ['span', 'userId'], -} as const; // eslint-disable-next-line import/no-default-export @Injectable() -export default class extends Endpoint { +export default class extends Endpoint<'charts/user/notes'> { + name = 'charts/user/notes' as const; constructor( private perUserNotesChart: PerUserNotesChart, ) { - super(meta, paramDef, async (ps, me) => { + super(async (ps, me) => { return await this.perUserNotesChart.getChart(ps.span, ps.limit, ps.offset ? new Date(ps.offset) : null, ps.userId); }); } diff --git a/packages/backend/src/server/api/endpoints/charts/user/pv.ts b/packages/backend/src/server/api/endpoints/charts/user/pv.ts index 8d1a9aee1..4b02b7785 100644 --- a/packages/backend/src/server/api/endpoints/charts/user/pv.ts +++ b/packages/backend/src/server/api/endpoints/charts/user/pv.ts @@ -1,36 +1,15 @@ import { Injectable } from '@nestjs/common'; -import { getJsonSchema } from '@/core/chart/core.js'; import { Endpoint } from '@/server/api/endpoint-base.js'; import PerUserPvChart from '@/core/chart/charts/per-user-pv.js'; -import { schema } from '@/core/chart/charts/entities/per-user-pv.js'; - -export const meta = { - tags: ['charts', 'users'], - - res: getJsonSchema(schema), - - allowGet: true, - cacheSec: 60 * 60, -} as const; - -export const paramDef = { - type: 'object', - properties: { - span: { type: 'string', enum: ['day', 'hour'] }, - limit: { type: 'integer', minimum: 1, maximum: 500, default: 30 }, - offset: { type: 'integer', nullable: true, default: null }, - userId: { type: 'string', format: 'misskey:id' }, - }, - required: ['span', 'userId'], -} as const; // eslint-disable-next-line import/no-default-export @Injectable() -export default class extends Endpoint { +export default class extends Endpoint<'charts/user/pv'> { + name = 'charts/user/pv' as const; constructor( private perUserPvChart: PerUserPvChart, ) { - super(meta, paramDef, async (ps, me) => { + super(async (ps, me) => { return await this.perUserPvChart.getChart(ps.span, ps.limit, ps.offset ? new Date(ps.offset) : null, ps.userId); }); } diff --git a/packages/backend/src/server/api/endpoints/charts/user/reactions.ts b/packages/backend/src/server/api/endpoints/charts/user/reactions.ts index f2ff41319..5afe77523 100644 --- a/packages/backend/src/server/api/endpoints/charts/user/reactions.ts +++ b/packages/backend/src/server/api/endpoints/charts/user/reactions.ts @@ -26,11 +26,12 @@ export const paramDef = { // eslint-disable-next-line import/no-default-export @Injectable() -export default class extends Endpoint { +export default class extends Endpoint<'charts/user/reactions'> { + name = 'charts/user/reactions' as const; constructor( private perUserReactionsChart: PerUserReactionsChart, ) { - super(meta, paramDef, async (ps, me) => { + super(async (ps, me) => { return await this.perUserReactionsChart.getChart(ps.span, ps.limit, ps.offset ? new Date(ps.offset) : null, ps.userId); }); } diff --git a/packages/misskey-js/src/endpoints.ts b/packages/misskey-js/src/endpoints.ts index 618665f62..689404c27 100644 --- a/packages/misskey-js/src/endpoints.ts +++ b/packages/misskey-js/src/endpoints.ts @@ -3028,6 +3028,66 @@ export const endpoints = { res: chartSchemaToJSONSchema(chartsSchemas.perUserFollowing) satisfies JSONSchema7, }], }, + 'charts/user/notes': { + tags: ['charts', 'users', 'notes'], + + allowGet: true, + cacheSec: 60 * 60, + + defines: [{ + req: { + type: 'object', + properties: { + span: { type: 'string', enum: ['day', 'hour'] }, + limit: { type: 'integer', minimum: 1, maximum: 500, default: 30 }, + offset: { type: 'integer', nullable: true, default: null }, + userId: { type: 'string', format: 'misskey:id' }, + }, + required: ['span', 'userId'], + }, + res: chartSchemaToJSONSchema(chartsSchemas.perUserNotes) satisfies JSONSchema7, + }], + }, + 'charts/user/pv': { + tags: ['charts', 'users'], + + allowGet: true, + cacheSec: 60 * 60, + + defines: [{ + req: { + type: 'object', + properties: { + span: { type: 'string', enum: ['day', 'hour'] }, + limit: { type: 'integer', minimum: 1, maximum: 500, default: 30 }, + offset: { type: 'integer', nullable: true, default: null }, + userId: { type: 'string', format: 'misskey:id' }, + }, + required: ['span', 'userId'], + }, + res: chartSchemaToJSONSchema(chartsSchemas.perUserPv) satisfies JSONSchema7, + }], + }, + 'charts/user/reactions': { + tags: ['charts', 'users', 'reactions'], + + allowGet: true, + cacheSec: 60 * 60, + + defines: [{ + req: { + type: 'object', + properties: { + span: { type: 'string', enum: ['day', 'hour'] }, + limit: { type: 'integer', minimum: 1, maximum: 500, default: 30 }, + offset: { type: 'integer', nullable: true, default: null }, + userId: { type: 'string', format: 'misskey:id' }, + }, + required: ['span', 'userId'], + }, + res: chartSchemaToJSONSchema(chartsSchemas.perUserReactions) satisfies JSONSchema7, + }], + }, //#endregion } as const satisfies { [x: string]: IEndpointMeta; };