Skip to content

Commit

Permalink
toaster: Hide builds for non-cli projects in analysis mode
Browse files Browse the repository at this point in the history
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@intel.com>
Signed-off-by: brian avery <avery.brian@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
  • Loading branch information
townxelliot authored and rpurdie committed Oct 27, 2015
1 parent b185865 commit 52de2c8
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions lib/toaster/toastergui/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -1926,6 +1929,11 @@ def builds(request):

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,
Expand Down Expand Up @@ -2000,7 +2008,7 @@ def _build_list_helper(request, queryset_all, redirect_page, pid=None):
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'})
Expand Down Expand Up @@ -3030,6 +3038,10 @@ def projects(request):
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)
Expand Down

0 comments on commit 52de2c8

Please sign in to comment.