From bccad5585ef32650b12fac8567a0642e22215f08 Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Tue, 19 Sep 2017 13:10:35 -0300 Subject: [PATCH] Adding statuses --- graph/loaders/users.js | 10 +++++++++- graph/typeDefs.graphql | 3 +++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/graph/loaders/users.js b/graph/loaders/users.js index 269512c60..dc58fffad 100644 --- a/graph/loaders/users.js +++ b/graph/loaders/users.js @@ -115,7 +115,7 @@ const getUsersByQuery = async ({user, loaders: {Actions}}, {ids, limit, cursor, * @return {Promise} resolves to the counts of the users from the * query */ -const getCountByQuery = async ({loaders: {Actions}}, {action_type}) => { +const getCountByQuery = async ({loaders: {Actions}}, {action_type, statuses}) => { let query = UserModel.find(); if (action_type) { @@ -128,6 +128,14 @@ const getCountByQuery = async ({loaders: {Actions}}, {action_type}) => { }); } + if (statuses) { + query = query.where({ + status: { + $in: statuses + } + }); + } + return UserModel .find(query) .count(); diff --git a/graph/typeDefs.graphql b/graph/typeDefs.graphql index 5b5ab8190..db296e45d 100644 --- a/graph/typeDefs.graphql +++ b/graph/typeDefs.graphql @@ -348,6 +348,9 @@ input UserCountQuery { # comments returned will only be ones which have at least one action of this # type. action_type: ACTION_TYPE + + # Current status of a user. + statuses: [USER_STATUS] } type EditInfo {