mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-04-14 19:56:23 +00:00
fix(challenges): handle case where challenge has no categories or result is empty
This commit is contained in:
parent
88bfed7efe
commit
276e882092
1 changed files with 17 additions and 11 deletions
|
|
@ -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');
|
||||
|
|
|
|||
Loading…
Reference in a new issue