2023-07-27 05:31:52 +00:00
|
|
|
/*
|
|
|
|
* SPDX-FileCopyrightText: syuilo and other misskey contributors
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
|
|
|
|
2023-02-16 14:09:41 +00:00
|
|
|
import { Injectable } from '@nestjs/common';
|
2022-09-17 18:27:08 +00:00
|
|
|
import { getJsonSchema } from '@/core/chart/core.js';
|
|
|
|
import { Endpoint } from '@/server/api/endpoint-base.js';
|
|
|
|
import DriveChart from '@/core/chart/charts/drive.js';
|
|
|
|
import { schema } from '@/core/chart/charts/entities/drive.js';
|
2018-10-21 00:20:11 +00:00
|
|
|
|
|
|
|
export const meta = {
|
2019-02-23 02:20:58 +00:00
|
|
|
tags: ['charts', 'drive'],
|
|
|
|
|
2022-09-17 18:27:08 +00:00
|
|
|
res: getJsonSchema(schema),
|
2022-06-25 09:26:31 +00:00
|
|
|
|
|
|
|
allowGet: true,
|
|
|
|
cacheSec: 60 * 60,
|
2022-02-19 05:05:32 +00:00
|
|
|
} as const;
|
2020-03-06 16:04:36 +00:00
|
|
|
|
2022-02-20 04:15:40 +00:00
|
|
|
export const paramDef = {
|
2022-02-19 05:05:32 +00:00
|
|
|
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 },
|
2019-02-23 02:20:58 +00:00
|
|
|
},
|
2022-02-19 05:05:32 +00:00
|
|
|
required: ['span'],
|
2022-01-18 13:27:10 +00:00
|
|
|
} as const;
|
2018-10-21 00:20:11 +00:00
|
|
|
|
2022-09-17 18:27:08 +00:00
|
|
|
@Injectable()
|
2023-08-17 12:20:58 +00:00
|
|
|
export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-disable-line import/no-default-export
|
2022-09-17 18:27:08 +00:00
|
|
|
constructor(
|
|
|
|
private driveChart: DriveChart,
|
|
|
|
) {
|
|
|
|
super(meta, paramDef, async (ps, me) => {
|
|
|
|
return await this.driveChart.getChart(ps.span, ps.limit, ps.offset ? new Date(ps.offset) : null);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|