From 80e5645a84cc60d76f79c48a3d565fb66ad88643 Mon Sep 17 00:00:00 2001 From: syuilo Date: Mon, 18 Jun 2018 09:54:53 +0900 Subject: wip --- src/server/api/endpoints/aggregation/users/reaction.ts | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'src/server/api/endpoints/aggregation/users/reaction.ts') diff --git a/src/server/api/endpoints/aggregation/users/reaction.ts b/src/server/api/endpoints/aggregation/users/reaction.ts index 2de2840258..adb5acfb4e 100644 --- a/src/server/api/endpoints/aggregation/users/reaction.ts +++ b/src/server/api/endpoints/aggregation/users/reaction.ts @@ -1,17 +1,11 @@ -/** - * Module dependencies - */ import $ from 'cafy'; import ID from '../../../../../cafy-id'; import User from '../../../../../models/user'; import Reaction from '../../../../../models/note-reaction'; /** * Aggregate reaction of a user - * - * @param {any} params - * @return {Promise} */ -module.exports = (params) => new Promise(async (res, rej) => { +module.exports = (params: any) => new Promise(async (res, rej) => { // Get 'userId' parameter const [userId, userIdErr] = $.type(ID).get(params.userId); if (userIdErr) return rej('invalid userId param'); @@ -48,7 +42,7 @@ module.exports = (params) => new Promise(async (res, rej) => { }} ]); - datas.forEach(data => { + datas.forEach((data: any) => { data.date = data._id; delete data._id; }); @@ -58,7 +52,7 @@ module.exports = (params) => new Promise(async (res, rej) => { for (let i = 0; i < 30; 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]; -- cgit v1.2.3-freya