summaryrefslogtreecommitdiff
path: root/src/server/api/endpoints/charts
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/api/endpoints/charts')
-rw-r--r--src/server/api/endpoints/charts/active-users.ts34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/server/api/endpoints/charts/active-users.ts b/src/server/api/endpoints/charts/active-users.ts
new file mode 100644
index 0000000000..5187e5b353
--- /dev/null
+++ b/src/server/api/endpoints/charts/active-users.ts
@@ -0,0 +1,34 @@
+import $ from 'cafy';
+import define from '../../define';
+import activeUsersChart from '../../../../chart/active-users';
+
+export const meta = {
+ stability: 'stable',
+
+ desc: {
+ 'ja-JP': 'アクティブユーザーのチャートを取得します。'
+ },
+
+ params: {
+ span: {
+ validator: $.str.or(['day', 'hour']),
+ desc: {
+ 'ja-JP': '集計のスパン (day または hour)'
+ }
+ },
+
+ limit: {
+ validator: $.num.optional.range(1, 500),
+ default: 30,
+ desc: {
+ 'ja-JP': '最大数。例えば 30 を指定したとすると、スパンが"day"の場合は30日分のデータが、スパンが"hour"の場合は30時間分のデータが返ります。'
+ }
+ },
+ }
+};
+
+export default define(meta, (ps) => new Promise(async (res, rej) => {
+ const stats = await activeUsersChart.getChart(ps.span as any, ps.limit);
+
+ res(stats);
+}));