mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 22:57:21 +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)
|
||||
.addFields({
|
||||
isOfficial: {
|
||||
$gt: [
|
||||
{
|
||||
$size: {
|
||||
$filter: {
|
||||
input: '$categories',
|
||||
as: 'cat',
|
||||
cond: {
|
||||
$eq: ['$$cat.slug', 'habitica_official'],
|
||||
$cond: {
|
||||
if: { $isArray: '$categories' },
|
||||
then: {
|
||||
$gt: [
|
||||
{
|
||||
$size: {
|
||||
$filter: {
|
||||
input: '$categories',
|
||||
as: 'cat',
|
||||
cond: {
|
||||
$eq: ['$$cat.slug', 'habitica_official'],
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
0,
|
||||
],
|
||||
},
|
||||
0,
|
||||
],
|
||||
else: false,
|
||||
},
|
||||
},
|
||||
})
|
||||
.sort('-isOfficial -createdAt');
|
||||
|
||||
Reference in New Issue
Block a user