[bitbake-devel] [PATCH 37/94] bitbake: webhob: add ordering capabilities to build api
Alex DAMIAN
alexandru.damian at intel.com
Tue Sep 24 16:52:06 UTC 2013
From: Calin Dragomir <calinx.l.dragomir at intel.com>
This patch adds the capability to order builds by a specific
field of the build model.
The format used is 'field_name:order' and the default ordering
is ascending.
Signed-off-by: Calin Dragomir <calinx.l.dragomir at intel.com>
Signed-off-by: Alexandru DAMIAN <alexandru.damian at intel.com>
---
bitbake/lib/webhob/bldviewer/views.py | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/bitbake/lib/webhob/bldviewer/views.py b/bitbake/lib/webhob/bldviewer/views.py
index de89b84..71e95b4 100644
--- a/bitbake/lib/webhob/bldviewer/views.py
+++ b/bitbake/lib/webhob/bldviewer/views.py
@@ -56,6 +56,7 @@ from django.http import HttpResponse
def builds(request):
+ DESCENDING = 'desc'
response_data = {}
try:
@@ -68,6 +69,7 @@ def builds(request):
except ValueError:
offset = 0
+ ordering_string = request.GET.get('orderby', '')
filter_string = request.GET.get('filter', '')
if filter_string:
@@ -91,6 +93,13 @@ def builds(request):
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), content_type='application/json')
--
1.8.1.2
More information about the bitbake-devel
mailing list