Patchwork [bitbake-devel,45/94] bitbake: webhob: fix ordering issue

login
register
mail settings
Submitter Alexandru DAMIAN
Date Sept. 24, 2013, 4:52 p.m.
Message ID <7603f3f6b9428b1bde94073522643b3fc8a03188.1380041477.git.alexandru.damian@intel.com>
Download mbox | patch
Permalink /patch/58791/
State New
Headers show

Comments

Alexandru DAMIAN - Sept. 24, 2013, 4:52 p.m.
From: Calin Dragomir <calinx.l.dragomir@intel.com>

This patch fixes the AssertionError issue that caused the
build page to break.
This happened because ordering cannot be done after a slicing
operation has been executed.
By placing the ordering before the slicing occurs, the issue
stops appearing.

Signed-off-by: Calin Dragomir <calinx.l.dragomir@intel.com>

Conflicts:
	bitbake/lib/webhob/bldviewer/views.py
---
 bitbake/lib/webhob/bldviewer/views.py | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

Patch

diff --git a/bitbake/lib/webhob/bldviewer/views.py b/bitbake/lib/webhob/bldviewer/views.py
index 423fdf7..a5c4387 100644
--- a/bitbake/lib/webhob/bldviewer/views.py
+++ b/bitbake/lib/webhob/bldviewer/views.py
@@ -110,6 +110,13 @@  def model_explorer(request, model_name):
     if search_term:
         queryset = _get_search_results(search_term, queryset, model)
 
+    if ordering_string and queryset:
+        column, order = ordering_string.split(':')
+        if order.lower() == DESCENDING:
+            queryset = queryset.order_by('-' + column)
+        else:
+            queryset = queryset.order_by(column)
+
     if offset and limit:
         queryset = queryset[offset:(offset+limit)]
     elif offset:
@@ -122,13 +129,6 @@  def model_explorer(request, model_name):
     else:
         response_data['count'] = 0
 
-    if queryset and ordering_string:
-        column, order = ordering_string.split(':')
-        if order.lower() == DESCENDING:
-            queryset = queryset.order_by('-' + column)
-        else:
-            queryset = queryset.order_by(column)
-
     response_data['list'] = serializers.serialize('json', queryset)
 
     return HttpResponse(json.dumps(response_data),