Skip to content

Commit d6116b7

Browse files
committed
null filter
1 parent fc86fa3 commit d6116b7

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

api/download.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@
2020
def _filter_check(property_filter, property_values):
2121
minus = set(property_filter.get('-', []))
2222
plus = set(property_filter.get('+', []))
23-
if not minus.isdisjoint(property_values):
23+
if "null" in plus and not property_values:
24+
return True
25+
if "null" in minus and property_values:
26+
return False
27+
elif not minus.isdisjoint(property_values):
2428
return False
2529
if plus and plus.isdisjoint(property_values):
2630
return False

test/integration_tests/python/test_download.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,8 @@ def test_filters(data_builder, file_form, as_admin):
388388
assert r.json()['file_cnt'] == 2
389389

390390
# Filter by type
391+
as_admin.post('/acquisitions/' + acquisition + '/files', files=file_form(
392+
"test", meta={'name': "test", 'tags': ['red', 'blue']}))
391393
r = as_admin.post('/download', json={
392394
'optional': False,
393395
'filters': [
@@ -399,6 +401,17 @@ def test_filters(data_builder, file_form, as_admin):
399401
})
400402
assert r.ok
401403
assert r.json()['file_cnt'] == 1
404+
r = as_admin.post('/download', json={
405+
'optional': False,
406+
'filters': [
407+
{'types': {'+':['null']}}
408+
],
409+
'nodes': [
410+
{'level': 'session', '_id': session},
411+
]
412+
})
413+
assert r.ok
414+
assert r.json()['file_cnt'] == 1
402415

403416
def test_summary(data_builder, as_admin, file_form):
404417
project = data_builder.create_project(label='project1')

0 commit comments

Comments
 (0)