From cbadbeb2390ec458243432bace6bea4b07cf6e06 Mon Sep 17 00:00:00 2001 From: Maksim Eltyshev Date: Sun, 13 Dec 2020 23:17:12 +0500 Subject: [PATCH] Fix loading deleted users on actions fetch. Closes #62 --- server/api/controllers/actions/index.js | 2 +- server/api/helpers/get-users.js | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/server/api/controllers/actions/index.js b/server/api/controllers/actions/index.js index be5f3f4a..dcb4942a 100755 --- a/server/api/controllers/actions/index.js +++ b/server/api/controllers/actions/index.js @@ -42,7 +42,7 @@ module.exports = { const actions = await sails.helpers.getActionsForCard(inputs.cardId, inputs.beforeId); const userIds = sails.helpers.mapRecords(actions, 'userId', true); - const users = await sails.helpers.getUsers(userIds); + const users = await sails.helpers.getUsers(userIds, true); return exits.success({ items: actions, diff --git a/server/api/helpers/get-users.js b/server/api/helpers/get-users.js index b52eb81d..a9df777f 100644 --- a/server/api/helpers/get-users.js +++ b/server/api/helpers/get-users.js @@ -4,12 +4,14 @@ module.exports = { type: 'json', custom: (value) => _.isArray(value) || _.isPlainObject(value), }, + withDeleted: { + type: 'boolean', + defaultsTo: false, + }, }, async fn(inputs, exits) { - const criteria = { - deletedAt: null, - }; + const criteria = {}; if (_.isArray(inputs.criteria)) { criteria.id = inputs.criteria; @@ -17,6 +19,10 @@ module.exports = { Object.assign(criteria, inputs.criteria); } + if (!inputs.withDeleted) { + criteria.deletedAt = null; + } + const users = await User.find(criteria).sort('id'); return exits.success(users);