From ec379642c3ff9f8dab62a3b8085ce5eee7d4380e Mon Sep 17 00:00:00 2001 From: gitgiggety Date: Tue, 14 Nov 2023 16:58:04 +0100 Subject: [PATCH] fix criterions once more * Fix handling of both missing and null/None values for includes / excludes * Handle criterions without values --- resources/lib/criterion_parser.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/resources/lib/criterion_parser.py b/resources/lib/criterion_parser.py index 75c9d4f..93a89f6 100644 --- a/resources/lib/criterion_parser.py +++ b/resources/lib/criterion_parser.py @@ -20,10 +20,10 @@ def parse_criterion(criterion): value = criterion.get('value', '') if isinstance(value, dict) and 'depth' in value: - if 'items' in value and value['items'] is not None: + if value.get('items') is not None: filter['value'] = list(map(lambda v: v['id'], value['items'])) - if 'excluded' in value: + if value.get('excluded'): filter['excludes'] = list(map(lambda v: v['id'], value['excluded'])) filter['depth'] = value['depth'] @@ -31,7 +31,7 @@ def parse_criterion(criterion): filter.update(value) elif isinstance(value, list): filter['value'] = list(map(lambda v: v['id'], value)) - elif value is not '': + elif 'value' in criterion: filter['value'] = value return filter