[bitbake-devel] [PATCH 46/94] bitbake: webhob: extend search for multiple terms
Alex DAMIAN
alexandru.damian at intel.com
Tue Sep 24 16:52:15 UTC 2013
From: Alexandru DAMIAN <alexandru.damian at intel.com>
We extend the search functionality as to be able to narrow
down search results based on multiple terms.
Signed-off-by: Alexandru DAMIAN <alexandru.damian at intel.com>
---
bitbake/lib/webhob/bldviewer/views.py | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/bitbake/lib/webhob/bldviewer/views.py b/bitbake/lib/webhob/bldviewer/views.py
index a5c4387..4f7b46c 100644
--- a/bitbake/lib/webhob/bldviewer/views.py
+++ b/bitbake/lib/webhob/bldviewer/views.py
@@ -169,10 +169,13 @@ def _validate_input(input, model):
return input, invalid
def _get_search_results(search_term, queryset, model):
- q_map = map(lambda x: Q(**{x+'__icontains': search_term}),
+ search_objects = []
+ for st in search_term.split(" "):
+ q_map = map(lambda x: Q(**{x+'__icontains': st}),
model.search_allowed_fields)
- search_object = reduce(operator.or_, q_map)
+ search_objects.append(reduce(operator.or_, q_map))
+ search_object = reduce(operator.and_, search_objects)
queryset = queryset.filter(search_object)
return queryset
--
1.8.1.2
More information about the bitbake-devel
mailing list