[Toaster] [review-request][PATCH 4/6] toaster: Hide builds for non-cli projects in analysis mode
Elliot Smith
elliot.smith at intel.com
Fri Oct 16 07:32:55 PDT 2015
The "latest builds" sections of the "all builds" page
show builds for all projects. This is not appropriate
for analysis mode, where we can only affect the command-line
builds project.
Modify the "latest builds" section to only show builds for
the command line builds project if in analysis mode.
Also rationalise where we get the queryset of latest builds from:
we have a _get_latest_builds() function which was being used
to get the latest builds in most places, but not all.
Also modify _get_latest_builds() to sort by started_on, rather
than primary key, as assuming that a higher primary key value equates
with later start time is incorrect.
[YOCTO #8514]
Signed-off-by: Elliot Smith <elliot.smith at intel.com>
---
bitbake/lib/toaster/toastergui/views.py | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/bitbake/lib/toaster/toastergui/views.py b/bitbake/lib/toaster/toastergui/views.py
index 10bbef5..d675f4f 100755
--- a/bitbake/lib/toaster/toastergui/views.py
+++ b/bitbake/lib/toaster/toastergui/views.py
@@ -92,9 +92,12 @@ def _get_latest_builds(prj=None):
if prj is not None:
queryset = queryset.filter(project = prj)
+ if not toastermain.settings.BUILD_MODE:
+ queryset = queryset.exclude(project__is_default=False)
+
return list(itertools.chain(
- queryset.filter(outcome=Build.IN_PROGRESS).order_by("-pk"),
- queryset.filter(outcome__lt=Build.IN_PROGRESS).order_by("-pk")[:3] ))
+ queryset.filter(outcome=Build.IN_PROGRESS).order_by("-started_on"),
+ queryset.filter(outcome__lt=Build.IN_PROGRESS).order_by("-started_on")[:3] ))
# a JSON-able dict of recent builds; for use in the Project page, xhr_ updates, and other places, as needed
@@ -1926,6 +1929,11 @@ if True:
queryset = Build.objects.all()
+ # if in analysis mode, exclude builds for all projects except
+ # command line builds
+ if not toastermain.settings.BUILD_MODE:
+ queryset = queryset.exclude(project__is_default=False)
+
redirect_page = resolve(request.path_info).url_name
context, pagesize, orderby = _build_list_helper(request,
@@ -2000,7 +2008,7 @@ if True:
build_info = _build_page_range(Paginator(queryset, pagesize), request.GET.get('page', 1))
# build view-specific information; this is rendered specifically in the builds page, at the top of the page (i.e. Recent builds)
- build_mru = Build.objects.order_by("-started_on")[:3]
+ build_mru = _get_latest_builds()[:3]
# calculate the exact begining of local today and yesterday, append context
context_date,today_begin,yesterday_begin = _add_daterange_context(queryset_all, request, {'started_on','completed_on'})
@@ -3030,6 +3038,10 @@ if True:
queryset_all = queryset_all.filter(Q(is_default=False) |
q_default_with_builds)
+ # if in BUILD_MODE, exclude everything but the command line builds project
+ if not toastermain.settings.BUILD_MODE:
+ queryset_all = queryset_all.exclude(is_default=False)
+
# boilerplate code that takes a request for an object type and returns a queryset
# for that object type. copypasta for all needed table searches
(filter_string, search_term, ordering_string) = _search_tuple(request, Project)
--
Elliot Smith
Software Engineer
Intel OTC
---------------------------------------------------------------------
Intel Corporation (UK) Limited
Registered No. 1134945 (England)
Registered Office: Pipers Way, Swindon SN3 1RJ
VAT No: 860 2173 47
This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
More information about the toaster
mailing list