in services/ui_backend_service/api/admin.py [0:0]
def filter_notifications(notification):
comp_operators = {
"eq": lambda a, b: a == b,
"ne": lambda a, b: a != b,
"lt": lambda a, b: a < b,
"le": lambda a, b: a <= b,
"gt": lambda a, b: a > b,
"ge": lambda a, b: a >= b,
}
try:
for q in request.query.keys():
if ":" in q:
field, op = q.split(":", 1)
else:
field, op = q, "eq"
# Make sure compare operator is supported, otherwise ignore
# Compare value is typecasted to match field type
if op in comp_operators:
field_val = notification.get(field, None)
if not field_val:
continue
comp_val = type(field_val)(request.query.get(q, None))
if not comp_val:
continue
if not comp_operators[op](field_val, comp_val):
return False
except:
pass
return True