wip
This commit is contained in:
parent
a5a9540eac
commit
59f4bf2a74
4 changed files with 69 additions and 50 deletions
|
@ -1,36 +1,15 @@
|
||||||
import { Injectable } from '@nestjs/common';
|
import { Injectable } from '@nestjs/common';
|
||||||
import { getJsonSchema } from '@/core/chart/core.js';
|
|
||||||
import { Endpoint } from '@/server/api/endpoint-base.js';
|
import { Endpoint } from '@/server/api/endpoint-base.js';
|
||||||
import PerUserNotesChart from '@/core/chart/charts/per-user-notes.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
|
// eslint-disable-next-line import/no-default-export
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export default class extends Endpoint<typeof meta, typeof paramDef> {
|
export default class extends Endpoint<'charts/user/notes'> {
|
||||||
|
name = 'charts/user/notes' as const;
|
||||||
constructor(
|
constructor(
|
||||||
private perUserNotesChart: PerUserNotesChart,
|
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);
|
return await this.perUserNotesChart.getChart(ps.span, ps.limit, ps.offset ? new Date(ps.offset) : null, ps.userId);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,36 +1,15 @@
|
||||||
import { Injectable } from '@nestjs/common';
|
import { Injectable } from '@nestjs/common';
|
||||||
import { getJsonSchema } from '@/core/chart/core.js';
|
|
||||||
import { Endpoint } from '@/server/api/endpoint-base.js';
|
import { Endpoint } from '@/server/api/endpoint-base.js';
|
||||||
import PerUserPvChart from '@/core/chart/charts/per-user-pv.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
|
// eslint-disable-next-line import/no-default-export
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export default class extends Endpoint<typeof meta, typeof paramDef> {
|
export default class extends Endpoint<'charts/user/pv'> {
|
||||||
|
name = 'charts/user/pv' as const;
|
||||||
constructor(
|
constructor(
|
||||||
private perUserPvChart: PerUserPvChart,
|
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);
|
return await this.perUserPvChart.getChart(ps.span, ps.limit, ps.offset ? new Date(ps.offset) : null, ps.userId);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,11 +26,12 @@ export const paramDef = {
|
||||||
|
|
||||||
// eslint-disable-next-line import/no-default-export
|
// eslint-disable-next-line import/no-default-export
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export default class extends Endpoint<typeof meta, typeof paramDef> {
|
export default class extends Endpoint<'charts/user/reactions'> {
|
||||||
|
name = 'charts/user/reactions' as const;
|
||||||
constructor(
|
constructor(
|
||||||
private perUserReactionsChart: PerUserReactionsChart,
|
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);
|
return await this.perUserReactionsChart.getChart(ps.span, ps.limit, ps.offset ? new Date(ps.offset) : null, ps.userId);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -3028,6 +3028,66 @@ export const endpoints = {
|
||||||
res: chartSchemaToJSONSchema(chartsSchemas.perUserFollowing) satisfies JSONSchema7,
|
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
|
//#endregion
|
||||||
} as const satisfies { [x: string]: IEndpointMeta; };
|
} as const satisfies { [x: string]: IEndpointMeta; };
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue