This commit is contained in:
syuilo
2018-10-22 22:00:54 +09:00
parent 172a0a85aa
commit 1af4f94338
2 changed files with 106 additions and 1 deletions

View File

@@ -0,0 +1,39 @@
import $ from 'cafy';
import getParams from '../../get-params';
import { hashtagStats } from '../../../../services/stats';
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時間分のデータが返ります。'
}
}),
tag: $.str.note({
desc: {
'ja-JP': '対象のハッシュタグ'
}
}),
}
};
export default (params: any) => new Promise(async (res, rej) => {
const [ps, psErr] = getParams(meta, params);
if (psErr) throw psErr;
const stats = await hashtagStats.getChart(ps.span as any, ps.limit, ps.tag);
res(stats);
});