From 1d17109d62f072ea836349805a08523a43f0475d Mon Sep 17 00:00:00 2001 From: Elliot Smith Date: Sat, 17 Oct 2015 10:45:51 -0700 Subject: bitbake: toaster: Hide builds for non-cli projects in analysis mode 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] (Bitbake rev: 52de2c8cd11fa743f8fd7cb0cf776eea622ac474) Signed-off-by: Elliot Smith Signed-off-by: brian avery Signed-off-by: Richard Purdie --- bitbake/lib/toaster/toastergui/views.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'bitbake') diff --git a/bitbake/lib/toaster/toastergui/views.py b/bitbake/lib/toaster/toastergui/views.py index 10bbef5ca4..d675f4f2d2 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) -- cgit v1.2.3-54-g00ecf