summaryrefslogtreecommitdiff
path: root/src/server/api/endpoints/charts/user/drive.ts
blob: 918fb62c6a1905ec3bbd6d2629045f3a02b0d29e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import $ from 'cafy';
import define from '../../../define';
import { ID } from '../../../../../misc/cafy-id';
import { convertLog } from '../../../../../services/chart/core';
import { perUserDriveChart } from '../../../../../services/chart';

export const meta = {
	stability: 'stable',

	desc: {
		'ja-JP': 'ユーザーごとのドライブのチャートを取得します。'
	},

	tags: ['charts', 'drive', 'users'],

	params: {
		span: {
			validator: $.str.or(['day', 'hour']),
			desc: {
				'ja-JP': '集計のスパン (day または hour)'
			}
		},

		limit: {
			validator: $.optional.num.range(1, 500),
			default: 30,
			desc: {
				'ja-JP': '最大数。例えば 30 を指定したとすると、スパンが"day"の場合は30日分のデータが、スパンが"hour"の場合は30時間分のデータが返ります。'
			}
		},

		userId: {
			validator: $.type(ID),
			desc: {
				'ja-JP': '対象のユーザーのID',
				'en-US': 'Target user ID'
			}
		}
	},

	res: convertLog(perUserDriveChart.schema),
};

export default define(meta, async (ps) => {
	return await perUserDriveChart.getChart(ps.span as any, ps.limit!, ps.userId);
});