mirror of
git://git.yoctoproject.org/layerindex-web.git
synced 2025-07-19 03:49:10 +02:00
views: support querying class inheritance
It's a little crude and certainly not optimal performance-wise, but we can support querying for recipes that inherit a particular class without too much trouble. This allows you to add "inherits:cmake" to the query and have it return only recipes that inherit the cmake class. You can use more than one inherits: item to filter down to recipes that inherit all of the specified classes. Note: this does not otherwise change the behaviour of specifying multiple words - all of the words other than those that start with "inherits:" are treated as part of a single phrase that will be searched for - not separate keywords. Fixes [YOCTO #9879]. Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
This commit is contained in:
parent
43203c578c
commit
a988b6ba08
|
@ -376,6 +376,22 @@ class RecipeSearchView(ListView):
|
|||
_check_url_branch(self.kwargs)
|
||||
query_string = self.request.GET.get('q', '')
|
||||
init_qs = Recipe.objects.filter(layerbranch__branch__name=self.kwargs['branch'])
|
||||
|
||||
# Support slightly crude search on inherits field
|
||||
query_items = query_string.split()
|
||||
inherits = []
|
||||
query_terms = []
|
||||
for item in query_items:
|
||||
if item.startswith('inherits:'):
|
||||
inherits.append(item.split(':')[1])
|
||||
else:
|
||||
query_terms.append(item)
|
||||
if inherits:
|
||||
# FIXME This is a bit ugly, perhaps we should consider having this as a one-many relationship instead
|
||||
for inherit in inherits:
|
||||
init_qs = init_qs.filter(Q(inherits=inherit) | Q(inherits__startswith=inherit + ' ') | Q(inherits__endswith=' ' + inherit) | Q(inherits__contains=' %s ' % inherit))
|
||||
query_string = ' '.join(query_terms)
|
||||
|
||||
if query_string.strip():
|
||||
order_by = ('pn', 'layerbranch__layer')
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user