aboutsummaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
authorElliot Smith <elliot.smith@intel.com>2016-01-18 14:23:55 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-02-10 13:29:20 +0000
commitefbffe3c298d57af34324639f2208e35735758a9 (patch)
tree211cb0601b9b1ed6fe6ad220cb03818080a3d725 /bitbake
parentb51478582f17bc9c43a92232e41246aec3e89f36 (diff)
downloadopenembedded-core-contrib-efbffe3c298d57af34324639f2208e35735758a9.tar.gz
bitbake: 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. (Bitbake rev: 5189252635ddc7b90c9a43aaed9f196c31e1dcad) 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>
Diffstat (limited to 'bitbake')
-rw-r--r--bitbake/lib/toaster/orm/models.py29
-rw-r--r--bitbake/lib/toaster/toastergui/tables.py33
-rw-r--r--bitbake/lib/toaster/toastergui/templates/mrb_section.html7
-rwxr-xr-xbitbake/lib/toaster/toastergui/views.py2
4 files changed, 46 insertions, 25 deletions
diff --git a/bitbake/lib/toaster/orm/models.py b/bitbake/lib/toaster/orm/models.py
index ba1eb0f2c8..1cf997cfe5 100644
--- a/bitbake/lib/toaster/orm/models.py
+++ b/bitbake/lib/toaster/orm/models.py
@@ -31,6 +31,7 @@ import django.db.models.signals
import os.path
import re
+import itertools
import logging
logger = logging.getLogger("toaster")
@@ -372,11 +373,37 @@ class Build(models.Model):
build_name = models.CharField(max_length=100)
bitbake_version = models.CharField(max_length=50)
+ @staticmethod
+ def get_recent(project=None):
+ """
+ Return recent builds as a list; if project is set, only return
+ builds for that project
+ """
+
+ builds = Build.objects.all()
+
+ if project:
+ builds = builds.filter(project=project)
+
+ finished_criteria = Q(outcome=Build.SUCCEEDED) | Q(outcome=Build.FAILED)
+
+ recent_builds = list(itertools.chain(
+ builds.filter(outcome=Build.IN_PROGRESS).order_by("-started_on"),
+ builds.filter(finished_criteria).order_by("-completed_on")[:3]
+ ))
+
+ # add percentage done property to each build; this is used
+ # to show build progress in mrb_section.html
+ for build in recent_builds:
+ build.percentDone = build.completeper()
+
+ return recent_builds
+
def completeper(self):
tf = Task.objects.filter(build = self)
tfc = tf.count()
if tfc > 0:
- completeper = tf.exclude(order__isnull=True).count()*100/tf.count()
+ completeper = tf.exclude(order__isnull=True).count()*100/tfc
else:
completeper = 0
return completeper
diff --git a/bitbake/lib/toaster/toastergui/tables.py b/bitbake/lib/toaster/toastergui/tables.py
index ba2726d070..7fb3f8605e 100644
--- a/bitbake/lib/toaster/toastergui/tables.py
+++ b/bitbake/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
diff --git a/bitbake/lib/toaster/toastergui/templates/mrb_section.html b/bitbake/lib/toaster/toastergui/templates/mrb_section.html
index 2e5eb5050b..da1253e1d5 100644
--- a/bitbake/lib/toaster/toastergui/templates/mrb_section.html
+++ b/bitbake/lib/toaster/toastergui/templates/mrb_section.html
@@ -165,7 +165,6 @@ $(document).ready(function(){
progressTimer = window.setInterval(function() {
libtoaster.getProjectInfo(libtoaster.ctx.projectPageUrl,
function(prjInfo){
-
/* These two are needed because a build can be 100% and still
* in progress due to the fact that the % done is updated at the
* start of a task so it can be doing the last task at 100%
@@ -176,18 +175,18 @@ $(document).ready(function(){
for (var i in prjInfo.builds){
var build = prjInfo.builds[i];
- if (build.status === "In Progress" ||
+ if (build.outcome === "In Progress" ||
$(".progress .bar").length > 0){
/* Update the build progress */
var percentDone;
- if (build.status !== "In Progress"){
+ if (build.outcome !== "In Progress"){
/* We have to ignore the value when it's Succeeded because it
* goes back to 0
*/
percentDone = 100;
} else {
- percentDone = build.build[0].completeper;
+ percentDone = build.percentDone;
inProgress++;
}
diff --git a/bitbake/lib/toaster/toastergui/views.py b/bitbake/lib/toaster/toastergui/views.py
index 9ad2746881..da73d43c4f 100755
--- a/bitbake/lib/toaster/toastergui/views.py
+++ b/bitbake/lib/toaster/toastergui/views.py
@@ -2008,7 +2008,7 @@ if True:
"completedbuilds": Build.objects.exclude(outcome = Build.IN_PROGRESS).filter(project_id = pid),
"prj" : {"name": prj.name, },
"buildrequests" : prj.build_set.filter(outcome=Build.IN_PROGRESS),
- #"builds" : _project_recent_build_list(prj),
+ "builds" : Build.get_recent(prj),
"layers" : map(lambda x: {
"id": x.layercommit.pk,
"orderid": x.pk,