Check there are ids in the badIds array

- if there are no ids, we shouldn't add an empty array since it adds unneccessarily to our auto-generated post query and affects greatly performance. see issue #1390
This commit is contained in:
Matt Rider 2019-08-26 16:19:42 +02:00
parent f11091c4ce
commit 75d984073d

View File

@ -11,17 +11,19 @@ const filterForBlockedUsers = async (params, context) => {
getBlockedByUsers(context),
])
const badIds = [...blockedByUsers.map(b => b.id), ...blockedUsers.map(b => b.id)]
params.filter = mergeWith(
params.filter,
{
author_not: { id_in: badIds },
},
(objValue, srcValue) => {
if (isArray(objValue)) {
return objValue.concat(srcValue)
}
},
)
if (badIds.length) {
params.filter = mergeWith(
params.filter,
{
author_not: { id_in: badIds },
},
(objValue, srcValue) => {
if (isArray(objValue)) {
return objValue.concat(srcValue)
}
},
)
}
return params
}