diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2018-03-28 16:39:14 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2018-03-28 16:39:14 +0900 |
| commit | 3d5cdb8d2d60932caf1d29b0581c7d6243e06e37 (patch) | |
| tree | 9c29d1062b08378d4c4cafe5976793616d45bc01 /src/api/endpoints/aggregation/posts/reactions.ts | |
| parent | wip (diff) | |
| download | sharkey-3d5cdb8d2d60932caf1d29b0581c7d6243e06e37.tar.gz sharkey-3d5cdb8d2d60932caf1d29b0581c7d6243e06e37.tar.bz2 sharkey-3d5cdb8d2d60932caf1d29b0581c7d6243e06e37.zip | |
wip
Diffstat (limited to 'src/api/endpoints/aggregation/posts/reactions.ts')
| -rw-r--r-- | src/api/endpoints/aggregation/posts/reactions.ts | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/api/endpoints/aggregation/posts/reactions.ts b/src/api/endpoints/aggregation/posts/reactions.ts index 790b523be9..2dc989281c 100644 --- a/src/api/endpoints/aggregation/posts/reactions.ts +++ b/src/api/endpoints/aggregation/posts/reactions.ts @@ -12,9 +12,9 @@ import Reaction from '../../../models/post-reaction'; * @return {Promise<any>} */ module.exports = (params) => new Promise(async (res, rej) => { - // Get 'post_id' parameter - const [postId, postIdErr] = $(params.post_id).id().$; - if (postIdErr) return rej('invalid post_id param'); + // Get 'postId' parameter + const [postId, postIdErr] = $(params.postId).id().$; + if (postIdErr) return rej('invalid postId param'); // Lookup post const post = await Post.findOne({ @@ -29,10 +29,10 @@ module.exports = (params) => new Promise(async (res, rej) => { const reactions = await Reaction .find({ - post_id: post._id, + postId: post._id, $or: [ - { deleted_at: { $exists: false } }, - { deleted_at: { $gt: startTime } } + { deletedAt: { $exists: false } }, + { deletedAt: { $gt: startTime } } ] }, { sort: { @@ -40,7 +40,7 @@ module.exports = (params) => new Promise(async (res, rej) => { }, fields: { _id: false, - post_id: false + postId: false } }); @@ -55,7 +55,7 @@ module.exports = (params) => new Promise(async (res, rej) => { // day = day.getTime(); const count = reactions.filter(r => - r.created_at < day && (r.deleted_at == null || r.deleted_at > day) + r.createdAt < day && (r.deletedAt == null || r.deletedAt > day) ).length; graph.push({ |