summaryrefslogtreecommitdiff
path: root/src/server/api/endpoints/aggregation/users/post.ts
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2018-04-08 02:30:37 +0900
committersyuilo <syuilotan@yahoo.co.jp>2018-04-08 02:30:37 +0900
commita1b490afa756a71b9cef4afa424575bc223bc612 (patch)
tree06de4d839e17b1e08e0891542af7360c701a154a /src/server/api/endpoints/aggregation/users/post.ts
parentMerge pull request #1392 from syuilo/greenkeeper/element-ui-2.3.3 (diff)
downloadsharkey-a1b490afa756a71b9cef4afa424575bc223bc612.tar.gz
sharkey-a1b490afa756a71b9cef4afa424575bc223bc612.tar.bz2
sharkey-a1b490afa756a71b9cef4afa424575bc223bc612.zip
Post --> Note
Closes #1411
Diffstat (limited to 'src/server/api/endpoints/aggregation/users/post.ts')
-rw-r--r--src/server/api/endpoints/aggregation/users/post.ts22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/server/api/endpoints/aggregation/users/post.ts b/src/server/api/endpoints/aggregation/users/post.ts
index 13617cf639..e6170d83e2 100644
--- a/src/server/api/endpoints/aggregation/users/post.ts
+++ b/src/server/api/endpoints/aggregation/users/post.ts
@@ -3,10 +3,10 @@
*/
import $ from 'cafy';
import User from '../../../../../models/user';
-import Post from '../../../../../models/post';
+import Note from '../../../../../models/note';
/**
- * Aggregate post of a user
+ * Aggregate note of a user
*
* @param {any} params
* @return {Promise<any>}
@@ -29,11 +29,11 @@ module.exports = (params) => new Promise(async (res, rej) => {
return rej('user not found');
}
- const datas = await Post
+ const datas = await Note
.aggregate([
{ $match: { userId: user._id } },
{ $project: {
- repostId: '$repostId',
+ renoteId: '$renoteId',
replyId: '$replyId',
createdAt: { $add: ['$createdAt', 9 * 60 * 60 * 1000] } // Convert into JST
}},
@@ -45,13 +45,13 @@ module.exports = (params) => new Promise(async (res, rej) => {
},
type: {
$cond: {
- if: { $ne: ['$repostId', null] },
- then: 'repost',
+ if: { $ne: ['$renoteId', null] },
+ then: 'renote',
else: {
$cond: {
if: { $ne: ['$replyId', null] },
then: 'reply',
- else: 'post'
+ else: 'note'
}
}
}
@@ -74,8 +74,8 @@ module.exports = (params) => new Promise(async (res, rej) => {
data.date = data._id;
delete data._id;
- data.posts = (data.data.filter(x => x.type == 'post')[0] || { count: 0 }).count;
- data.reposts = (data.data.filter(x => x.type == 'repost')[0] || { count: 0 }).count;
+ 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;
delete data.data;
@@ -99,8 +99,8 @@ module.exports = (params) => new Promise(async (res, rej) => {
month: day.getMonth() + 1, // In JavaScript, month is zero-based.
day: day.getDate()
},
- posts: 0,
- reposts: 0,
+ notes: 0,
+ renotes: 0,
replies: 0
});
}