summaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
authorDavid Reyna <David.Reyna@windriver.com>2014-03-26 16:24:43 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2014-04-01 10:22:43 +0100
commit4638e52ed2e146c43890dc9fba28031f6cc583ad (patch)
tree0f73588f509a00a7ff5b97c2d7cf43f019688ea5 /bitbake
parent362b71a07c714ebe03df40beecaca99dc9447e0c (diff)
downloadpoky-4638e52ed2e146c43890dc9fba28031f6cc583ad.tar.gz
bitbake: toaster: secondary sort key as table's default order
Provide for a secondary sort key based on the table's default ordering when doing sort on alternate columns. [YOCTO #5920] (Bitbake rev: 1a0defce1499fdc320bcb27b41e06bea2ca2aef2) Signed-off-by: David Reyna <David.Reyna@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r--bitbake/lib/toaster/toastergui/views.py27
1 files changed, 16 insertions, 11 deletions
diff --git a/bitbake/lib/toaster/toastergui/views.py b/bitbake/lib/toaster/toastergui/views.py
index 6028d4d775..05e24ea139 100644
--- a/bitbake/lib/toaster/toastergui/views.py
+++ b/bitbake/lib/toaster/toastergui/views.py
@@ -175,7 +175,7 @@ def _search_tuple(request, model):
175 175
176 176
177# returns a lazy-evaluated queryset for a filter/search/order combination 177# returns a lazy-evaluated queryset for a filter/search/order combination
178def _get_queryset(model, queryset, filter_string, search_term, ordering_string): 178def _get_queryset(model, queryset, filter_string, search_term, ordering_string, ordering_secondary=''):
179 if filter_string: 179 if filter_string:
180 filter_query = _get_filtering_query(filter_string) 180 filter_query = _get_filtering_query(filter_string)
181 queryset = queryset.filter(filter_query) 181 queryset = queryset.filter(filter_query)
@@ -187,14 +187,19 @@ def _get_queryset(model, queryset, filter_string, search_term, ordering_string):
187 187
188 if ordering_string and queryset: 188 if ordering_string and queryset:
189 column, order = ordering_string.split(':') 189 column, order = ordering_string.split(':')
190 if column == re.sub('-','',ordering_secondary):
191 ordering_secondary=''
190 if order.lower() == DESCENDING: 192 if order.lower() == DESCENDING:
191 queryset = queryset.order_by('-' + column) 193 column = '-' + column
194 if ordering_secondary:
195 queryset = queryset.order_by(column, ordering_secondary)
192 else: 196 else:
193 queryset = queryset.order_by(column) 197 queryset = queryset.order_by(column)
194 198
195 # insure only distinct records (e.g. from multiple search hits) are returned 199 # insure only distinct records (e.g. from multiple search hits) are returned
196 return queryset.distinct() 200 return queryset.distinct()
197 201
202
198# shows the "all builds" page 203# shows the "all builds" page
199def builds(request): 204def builds(request):
200 template = 'build.html' 205 template = 'build.html'
@@ -210,8 +215,8 @@ def builds(request):
210 # for that object type. copypasta for all needed table searches 215 # for that object type. copypasta for all needed table searches
211 (filter_string, search_term, ordering_string) = _search_tuple(request, Build) 216 (filter_string, search_term, ordering_string) = _search_tuple(request, Build)
212 queryset_all = Build.objects.exclude(outcome = Build.IN_PROGRESS) 217 queryset_all = Build.objects.exclude(outcome = Build.IN_PROGRESS)
213 queryset_with_search = _get_queryset(Build, queryset_all, None, search_term, ordering_string) 218 queryset_with_search = _get_queryset(Build, queryset_all, None, search_term, ordering_string, '-completed_on')
214 queryset = _get_queryset(Build, queryset_all, filter_string, search_term, ordering_string) 219 queryset = _get_queryset(Build, queryset_all, filter_string, search_term, ordering_string, '-completed_on')
215 220
216 # retrieve the objects that will be displayed in the table; builds a paginator and gets a page range to display 221 # retrieve the objects that will be displayed in the table; builds a paginator and gets a page range to display
217 build_info = _build_page_range(Paginator(queryset, request.GET.get('count', 10)),request.GET.get('page', 1)) 222 build_info = _build_page_range(Paginator(queryset, request.GET.get('count', 10)),request.GET.get('page', 1))
@@ -489,7 +494,7 @@ def target(request, build_id, target_id):
489 # FUTURE: get rid of nested sub-queries replacing with ManyToMany field 494 # FUTURE: get rid of nested sub-queries replacing with ManyToMany field
490 queryset = Package.objects.filter(size__gte=0, id__in=Target_Installed_Package.objects.filter(target_id=target_id).values('package_id')) 495 queryset = Package.objects.filter(size__gte=0, id__in=Target_Installed_Package.objects.filter(target_id=target_id).values('package_id'))
491 packages_sum = queryset.aggregate(Sum('installed_size')) 496 packages_sum = queryset.aggregate(Sum('installed_size'))
492 queryset = _get_queryset(Package, queryset, filter_string, search_term, ordering_string) 497 queryset = _get_queryset(Package, queryset, filter_string, search_term, ordering_string, 'name')
493 packages = _build_page_range(Paginator(queryset, request.GET.get('count', 25)),request.GET.get('page', 1)) 498 packages = _build_page_range(Paginator(queryset, request.GET.get('count', 25)),request.GET.get('page', 1))
494 499
495 # bring in package dependencies 500 # bring in package dependencies
@@ -789,8 +794,8 @@ def tasks_common(request, build_id, variant):
789 return _redirect_parameters( variant, request.GET, mandatory_parameters, build_id = build_id) 794 return _redirect_parameters( variant, request.GET, mandatory_parameters, build_id = build_id)
790 (filter_string, search_term, ordering_string) = _search_tuple(request, Task) 795 (filter_string, search_term, ordering_string) = _search_tuple(request, Task)
791 queryset_all = Task.objects.filter(build=build_id, order__gt=0) 796 queryset_all = Task.objects.filter(build=build_id, order__gt=0)
792 queryset_with_search = _get_queryset(Task, queryset_all, None , search_term, ordering_string) 797 queryset_with_search = _get_queryset(Task, queryset_all, None , search_term, ordering_string, 'order')
793 queryset = _get_queryset(Task, queryset_all, filter_string, search_term, ordering_string) 798 queryset = _get_queryset(Task, queryset_all, filter_string, search_term, ordering_string, 'order')
794 799
795 tasks = _build_page_range(Paginator(queryset, request.GET.get('count', 100)),request.GET.get('page', 1)) 800 tasks = _build_page_range(Paginator(queryset, request.GET.get('count', 100)),request.GET.get('page', 1))
796 801
@@ -952,7 +957,7 @@ def recipes(request, build_id):
952 return _redirect_parameters( 'recipes', request.GET, mandatory_parameters, build_id = build_id) 957 return _redirect_parameters( 'recipes', request.GET, mandatory_parameters, build_id = build_id)
953 (filter_string, search_term, ordering_string) = _search_tuple(request, Recipe) 958 (filter_string, search_term, ordering_string) = _search_tuple(request, Recipe)
954 queryset = Recipe.objects.filter(layer_version__id__in=Layer_Version.objects.filter(build=build_id)) 959 queryset = Recipe.objects.filter(layer_version__id__in=Layer_Version.objects.filter(build=build_id))
955 queryset = _get_queryset(Recipe, queryset, filter_string, search_term, ordering_string) 960 queryset = _get_queryset(Recipe, queryset, filter_string, search_term, ordering_string, 'name')
956 961
957 recipes = _build_page_range(Paginator(queryset, request.GET.get('count', 100)),request.GET.get('page', 1)) 962 recipes = _build_page_range(Paginator(queryset, request.GET.get('count', 100)),request.GET.get('page', 1))
958 963
@@ -1081,8 +1086,8 @@ def configvars(request, build_id):
1081 return _redirect_parameters( 'configvars', request.GET, mandatory_parameters, build_id = build_id) 1086 return _redirect_parameters( 'configvars', request.GET, mandatory_parameters, build_id = build_id)
1082 1087
1083 queryset = Variable.objects.filter(build=build_id).exclude(variable_name__istartswith='B_').exclude(variable_name__istartswith='do_') 1088 queryset = Variable.objects.filter(build=build_id).exclude(variable_name__istartswith='B_').exclude(variable_name__istartswith='do_')
1084 queryset_with_search = _get_queryset(Variable, queryset, None, search_term, ordering_string).exclude(variable_value='',vhistory__file_name__isnull=True) 1089 queryset_with_search = _get_queryset(Variable, queryset, None, search_term, ordering_string, 'variable_name').exclude(variable_value='',vhistory__file_name__isnull=True)
1085 queryset = _get_queryset(Variable, queryset, filter_string, search_term, ordering_string) 1090 queryset = _get_queryset(Variable, queryset, filter_string, search_term, ordering_string, 'variable_name')
1086 # remove records where the value is empty AND there are no history files 1091 # remove records where the value is empty AND there are no history files
1087 queryset = queryset.exclude(variable_value='',vhistory__file_name__isnull=True) 1092 queryset = queryset.exclude(variable_value='',vhistory__file_name__isnull=True)
1088 1093
@@ -1163,7 +1168,7 @@ def bpackage(request, build_id):
1163 return _redirect_parameters( 'packages', request.GET, mandatory_parameters, build_id = build_id) 1168 return _redirect_parameters( 'packages', request.GET, mandatory_parameters, build_id = build_id)
1164 (filter_string, search_term, ordering_string) = _search_tuple(request, Package) 1169 (filter_string, search_term, ordering_string) = _search_tuple(request, Package)
1165 queryset = Package.objects.filter(build = build_id).filter(size__gte=0) 1170 queryset = Package.objects.filter(build = build_id).filter(size__gte=0)
1166 queryset = _get_queryset(Package, queryset, filter_string, search_term, ordering_string) 1171 queryset = _get_queryset(Package, queryset, filter_string, search_term, ordering_string, 'name')
1167 1172
1168 packages = _build_page_range(Paginator(queryset, request.GET.get('count', 100)),request.GET.get('page', 1)) 1173 packages = _build_page_range(Paginator(queryset, request.GET.get('count', 100)),request.GET.get('page', 1))
1169 1174