aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2013-03-20 12:04:54 +0000
committerPaul Eggleton <paul.eggleton@linux.intel.com>2013-03-20 17:04:56 +0000
commit342ff28648d01e783aed4013f9c20fa016c99833 (patch)
treec210a08dd99609135027979b8315f6d286cce362
parent42d710b640b421f5a66922755d0ddc8d73a0ab03 (diff)
downloadopenembedded-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>
-rw-r--r--TODO1
-rw-r--r--layerindex/static/css/additional.css4
-rw-r--r--layerindex/views.py27
-rw-r--r--templates/layerindex/recipes.html13
4 files changed, 41 insertions, 4 deletions
diff --git a/TODO b/TODO
index 0e91ba54e4..cca4a12b03 100644
--- a/TODO
+++ b/TODO
@@ -10,7 +10,6 @@ Later:
* Add link to the all layers and all recipes tables from the layer details page?
* Display no-results found message when search does not return any results (all tables)
* Change behaviour of filter menus to stay open so that you can check / uncheck multiple items
-* Show recipes from non-software/base layers differently in recipes list
* Show layer type in layer detail?
* Usage links in list page?
* Avoid page content changing size depending on whether scrollbar is there or not?
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)
diff --git a/templates/layerindex/recipes.html b/templates/layerindex/recipes.html
index 36749de38e..f400442467 100644
--- a/templates/layerindex/recipes.html
+++ b/templates/layerindex/recipes.html
@@ -50,7 +50,7 @@
<tbody>
{% for recipe in recipe_list %}
- <tr>
+ <tr {% if recipe.preferred_count > 0 %}class="muted"{% endif %}>
<td><a href="{% url recipe recipe.id %}">{{ recipe.name }}</a></td>
<td>{{ recipe.pv }}</td>
<td>{{ recipe.short_desc }}</td>
@@ -77,3 +77,14 @@
{% endautoescape %}
{% endblock %}
+
+
+{% block scripts %}
+<script>
+ $(document).ready(function() {
+ firstfield = $("#filter-form input:text").first()
+ if( ! firstfield.val() )
+ firstfield.focus()
+ });
+</script>
+{% endblock %}