diff options
author | Paul Eggleton <paul.eggleton@linux.intel.com> | 2013-03-20 12:04:54 +0000 |
---|---|---|
committer | Paul Eggleton <paul.eggleton@linux.intel.com> | 2013-03-20 17:04:56 +0000 |
commit | 342ff28648d01e783aed4013f9c20fa016c99833 (patch) | |
tree | c210a08dd99609135027979b8315f6d286cce362 /layerindex | |
parent | 42d710b640b421f5a66922755d0ddc8d73a0ab03 (diff) | |
download | openembedded-core-contrib-342ff28648d01e783aed4013f9c20fa016c99833.tar.gz |
De-emphasise recipes where there is a more preferred version available
If another recipe exists with the same name in a different layer and
that other layer is "older" (by layer ID) and is a software or base
layer then lighten the recipe entry in the search results as it may
not be the preferred version (e.g. recipes in BSP or distro layers may
have been customised specifically for the machine or distro).
This has had a performance impact on the recipes list; as a result
showing all recipes by default has been disabled. If the user really
wants to see all recipes they can just leave the search box blank and
hit the search button.
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Diffstat (limited to 'layerindex')
-rw-r--r-- | layerindex/static/css/additional.css | 4 | ||||
-rw-r--r-- | layerindex/views.py | 27 |
2 files changed, 29 insertions, 2 deletions
diff --git a/layerindex/static/css/additional.css b/layerindex/static/css/additional.css index cd99fdd82f..1e2e7b3eb5 100644 --- a/layerindex/static/css/additional.css +++ b/layerindex/static/css/additional.css @@ -156,3 +156,7 @@ padding: 8px; background-color: white; height: 100%; } + +.muted a { + color: #66B8E0; +} diff --git a/layerindex/views.py b/layerindex/views.py index 9e613176fd..89822ba798 100644 --- a/layerindex/views.py +++ b/layerindex/views.py @@ -247,9 +247,32 @@ class RecipeSearchView(ListView): init_qs = Recipe.objects.filter(layerbranch__branch__name=self.request.session.get('branch', 'master')) if query_string.strip(): entry_query = simplesearch.get_query(query_string, ['pn', 'summary', 'description', 'filename']) - return init_qs.filter(entry_query).order_by('pn', 'layerbranch__layer') + qs = init_qs.filter(entry_query).order_by('pn', 'layerbranch__layer') else: - return init_qs.order_by('pn', 'layerbranch__layer') + if 'q' in self.request.GET: + qs = init_qs.order_by('pn', 'layerbranch__layer') + else: + # It's a bit too slow to return all records by default, and most people + # won't actually want that (if they do they can just hit the search button + # with no query string) + return Recipe.objects.none() + + # Add extra column so we can show "duplicate" recipes from other layers de-emphasised + # (it's a bit crude having to do this using SQL but I couldn't find a better way...) + return qs.extra( + select={ + 'preferred_count': """SELECT COUNT(1) +FROM layerindex_recipe AS recipe2 +, layerindex_layerbranch as branch2 +, layerindex_layeritem as layer2 +WHERE branch2.id = recipe2.layerbranch_id +AND layer2.id = branch2.layer_id +AND layer2.layer_type in ('S', 'A') +AND recipe2.pn = layerindex_recipe.pn +AND recipe2.layerbranch_id < layerindex_recipe.layerbranch_id +""" + }, + ) def get_context_data(self, **kwargs): context = super(RecipeSearchView, self).get_context_data(**kwargs) |