Skip to content

Commit

Permalink
fix criterions once more
Browse files Browse the repository at this point in the history
* Fix handling of both missing and null/None values for includes / excludes
* Handle criterions without values
  • Loading branch information
gitgiggety committed Nov 14, 2023
1 parent b58f74a commit ec37964
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions resources/lib/criterion_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,18 @@ 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']
elif isinstance(value, dict) and not value.keys() - ['value', 'value2']:
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

0 comments on commit ec37964

Please sign in to comment.