mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-19 07:37:25 +01:00
fix(challenges): handle case where challenge has no categories or result is empty
This commit is contained in:
@@ -117,20 +117,26 @@ export function createChallengeQuery (query) {
|
|||||||
.match(query)
|
.match(query)
|
||||||
.addFields({
|
.addFields({
|
||||||
isOfficial: {
|
isOfficial: {
|
||||||
$gt: [
|
$cond: {
|
||||||
{
|
if: { $isArray: '$categories' },
|
||||||
$size: {
|
then: {
|
||||||
$filter: {
|
$gt: [
|
||||||
input: '$categories',
|
{
|
||||||
as: 'cat',
|
$size: {
|
||||||
cond: {
|
$filter: {
|
||||||
$eq: ['$$cat.slug', 'habitica_official'],
|
input: '$categories',
|
||||||
|
as: 'cat',
|
||||||
|
cond: {
|
||||||
|
$eq: ['$$cat.slug', 'habitica_official'],
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
0,
|
||||||
|
],
|
||||||
},
|
},
|
||||||
0,
|
else: false,
|
||||||
],
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
.sort('-isOfficial -createdAt');
|
.sort('-isOfficial -createdAt');
|
||||||
|
|||||||
Reference in New Issue
Block a user