From 44c679895960baf611d9c70cd28eca2475c05f1a Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Tue, 29 Aug 2017 00:20:36 +0700 Subject: [PATCH] Fix action_type query --- graph/loaders/comments.js | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/graph/loaders/comments.js b/graph/loaders/comments.js index cafd647af..396f953ce 100644 --- a/graph/loaders/comments.js +++ b/graph/loaders/comments.js @@ -11,6 +11,7 @@ const { CACHE_EXPIRY_COMMENT_COUNT } = require('../../config'); const ms = require('ms'); +const sc = require('snake-case'); const CommentModel = require('../../models/comment'); @@ -112,10 +113,8 @@ const getCommentCountByQuery = (context, {ids, statuses, asset_id, parent_id, au if (context.user != null && context.user.can(SEARCH_OTHERS_COMMENTS) && action_type) { query = query.where({ - action_counts: { - [action_type.toLowerCase()]: { - $gt: 0, - } + [`action_counts.${sc(action_type.toLowerCase())}`]: { + $gt: 0, }, }); } @@ -298,10 +297,8 @@ const getCommentsByQuery = async (ctx, {ids, statuses, asset_id, parent_id, auth if (ctx.user != null && ctx.user.can(SEARCH_OTHERS_COMMENTS) && action_type) { comments = comments.where({ - action_counts: { - [action_type.toLowerCase()]: { - $gt: 0, - } + [`action_counts.${sc(action_type.toLowerCase())}`]: { + $gt: 0, }, }); }