summaryrefslogtreecommitdiffstats
path: root/lib/toaster/toastergui/tables.py
diff options
context:
space:
mode:
authorElliot Smith <elliot.smith@intel.com>2016-01-18 14:23:55 +0000
committerbrian avery <avery.brian@gmail.com>2016-02-08 12:48:13 -0800
commit5189252635ddc7b90c9a43aaed9f196c31e1dcad (patch)
treeb95bd8add7b68a1c62342ac81cef2beae1b8de67 /lib/toaster/toastergui/tables.py
parentdf8185fcbd84061976d91b03b2a9268b319a6184 (diff)
downloadbitbake-5189252635ddc7b90c9a43aaed9f196c31e1dcad.tar.gz
toaster: move recent builds query to model
The progress updater for the recent builds section makes a JSON call to the project view URL to get progress for each build. However, conversion of the builds pages to ToasterTable broke this, as the JSON response no longer contained the data necessary to populate the progress bars. Move the recent builds query to the Build model, so that it is accessible to the ToasterTables using it ("project builds" and "all builds"), as well as to the "project" view. Modify the code in the recent builds template to use the slightly different objects returned by the recent builds query on Build. Signed-off-by: Elliot Smith <elliot.smith@intel.com> Signed-off-by: brian avery <avery.brian@gmail.com>
Diffstat (limited to 'lib/toaster/toastergui/tables.py')
-rw-r--r--lib/toaster/toastergui/tables.py33
1 files changed, 14 insertions, 19 deletions
diff --git a/lib/toaster/toastergui/tables.py b/lib/toaster/toastergui/tables.py
index ba2726d07..7fb3f8605 100644
--- a/lib/toaster/toastergui/tables.py
+++ b/lib/toaster/toastergui/tables.py
@@ -28,7 +28,6 @@ from django.conf.urls import url
from django.core.urlresolvers import reverse, resolve
from django.http import HttpResponse
from django.views.generic import TemplateView
-import itertools
from toastergui.tablefilter import TableFilter
from toastergui.tablefilter import TableFilterActionToggle
@@ -1060,17 +1059,9 @@ class BuildsTable(ToasterTable):
def get_context_data(self, **kwargs):
context = super(BuildsTable, self).get_context_data(**kwargs)
- # for the latest builds section
- builds = self.get_builds()
+ # should be set in subclasses
+ context['mru'] = []
- finished_criteria = Q(outcome=Build.SUCCEEDED) | Q(outcome=Build.FAILED)
-
- latest_builds = itertools.chain(
- builds.filter(outcome=Build.IN_PROGRESS).order_by("-started_on"),
- builds.filter(finished_criteria).order_by("-completed_on")[:3]
- )
-
- context['mru'] = list(latest_builds)
context['mrb_type'] = self.mrb_type
return context
@@ -1481,6 +1472,12 @@ class AllBuildsTable(BuildsTable):
static_data_name='project',
static_data_template=project_template)
+ def get_context_data(self, **kwargs):
+ """ Get all builds for the recent builds area """
+ context = super(AllBuildsTable, self).get_context_data(**kwargs)
+ context['mru'] = Build.get_recent()
+ return context
+
class ProjectBuildsTable(BuildsTable):
"""
Builds page for a single project; a BuildsTable, with the queryset
@@ -1521,18 +1518,16 @@ class ProjectBuildsTable(BuildsTable):
def get_context_data(self, **kwargs):
"""
+ Get recent builds for this project, and the project itself
+
NOTE: self.project_id must be set before calling super(),
as it's used in get_context_data()
"""
self.project_id = kwargs['pid']
-
context = super(ProjectBuildsTable, self).get_context_data(**kwargs)
- context['project'] = Project.objects.get(pk=self.project_id)
-
- return context
-
- def get_builds(self):
- """ override: only return builds for the relevant project """
project = Project.objects.get(pk=self.project_id)
- return Build.objects.filter(project=project)
+ context['mru'] = Build.get_recent(project)
+ context['project'] = project
+
+ return context