summaryrefslogtreecommitdiff
path: root/src/server/api/endpoints/aggregation/posts.ts
diff options
context:
space:
mode:
authorsyuilo <Syuilotan@yahoo.co.jp>2018-06-18 14:43:56 +0900
committerGitHub <noreply@github.com>2018-06-18 14:43:56 +0900
commit5d3943ffa8cb4090c5c111397e266d255cc2212b (patch)
tree46f692fb21005bdc89499ea012c2436e8a2e90c0 /src/server/api/endpoints/aggregation/posts.ts
parentNew translations ja.yml (Spanish) (diff)
parentyatta (diff)
downloadmisskey-5d3943ffa8cb4090c5c111397e266d255cc2212b.tar.gz
misskey-5d3943ffa8cb4090c5c111397e266d255cc2212b.tar.bz2
misskey-5d3943ffa8cb4090c5c111397e266d255cc2212b.zip
Merge branch 'master' into l10n_master
Diffstat (limited to 'src/server/api/endpoints/aggregation/posts.ts')
-rw-r--r--src/server/api/endpoints/aggregation/posts.ts15
1 files changed, 6 insertions, 9 deletions
diff --git a/src/server/api/endpoints/aggregation/posts.ts b/src/server/api/endpoints/aggregation/posts.ts
index d348cadae9..48e344312d 100644
--- a/src/server/api/endpoints/aggregation/posts.ts
+++ b/src/server/api/endpoints/aggregation/posts.ts
@@ -1,13 +1,10 @@
-/**
- * Module dependencies
- */
import $ from 'cafy';
import Note from '../../../../models/note';
/**
* Aggregate notes
*/
-module.exports = params => new Promise(async (res, rej) => {
+module.exports = (params: any) => new Promise(async (res, rej) => {
// Get 'limit' parameter
const [limit = 365, limitErr] = $.num.optional().range(1, 365).get(params.limit);
if (limitErr) return rej('invalid limit param');
@@ -52,13 +49,13 @@ module.exports = params => new Promise(async (res, rej) => {
} }
]);
- datas.forEach(data => {
+ datas.forEach((data: any) => {
data.date = data._id;
delete data._id;
- data.notes = (data.data.filter(x => x.type == 'note')[0] || { count: 0 }).count;
- data.renotes = (data.data.filter(x => x.type == 'renote')[0] || { count: 0 }).count;
- data.replies = (data.data.filter(x => x.type == 'reply')[0] || { count: 0 }).count;
+ data.notes = (data.data.filter((x: any) => x.type == 'note')[0] || { count: 0 }).count;
+ data.renotes = (data.data.filter((x: any) => x.type == 'renote')[0] || { count: 0 }).count;
+ data.replies = (data.data.filter((x: any) => x.type == 'reply')[0] || { count: 0 }).count;
delete data.data;
});
@@ -68,7 +65,7 @@ module.exports = params => new Promise(async (res, rej) => {
for (let i = 0; i < limit; i++) {
const day = new Date(new Date().setDate(new Date().getDate() - i));
- const data = datas.filter(d =>
+ const data = datas.filter((d: any) =>
d.date.year == day.getFullYear() && d.date.month == day.getMonth() + 1 && d.date.day == day.getDate()
)[0];