summaryrefslogtreecommitdiff
path: root/src/server/api/endpoints
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/api/endpoints')
-rw-r--r--src/server/api/endpoints/charts/user/reactions.ts41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/server/api/endpoints/charts/user/reactions.ts b/src/server/api/endpoints/charts/user/reactions.ts
new file mode 100644
index 0000000000..1d1e7d5a44
--- /dev/null
+++ b/src/server/api/endpoints/charts/user/reactions.ts
@@ -0,0 +1,41 @@
+import $ from 'cafy';
+import getParams from '../../../get-params';
+import { perUserReactionsStats } from '../../../../../services/stats';
+import ID from '../../../../../misc/cafy-id';
+
+export const meta = {
+ desc: {
+ 'ja-JP': 'ユーザーごとの被リアクション数の統計を取得します。'
+ },
+
+ params: {
+ span: $.str.or(['day', 'hour']).note({
+ desc: {
+ 'ja-JP': '集計のスパン (day または hour)'
+ }
+ }),
+
+ limit: $.num.optional.range(1, 100).note({
+ default: 30,
+ desc: {
+ 'ja-JP': '最大数。例えば 30 を指定したとすると、スパンが"day"の場合は30日分のデータが、スパンが"hour"の場合は30時間分のデータが返ります。'
+ }
+ }),
+
+ userId: $.type(ID).note({
+ desc: {
+ 'ja-JP': '対象のユーザーのID',
+ 'en-US': 'Target user ID'
+ }
+ })
+ }
+};
+
+export default (params: any) => new Promise(async (res, rej) => {
+ const [ps, psErr] = getParams(meta, params);
+ if (psErr) throw psErr;
+
+ const stats = await perUserReactionsStats.getChart(ps.span as any, ps.limit, ps.userId);
+
+ res(stats);
+});