summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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
31 31
32import os.path 32import os.path
33import re 33import re
34import itertools
34 35
35import logging 36import logging
36logger = logging.getLogger("toaster") 37logger = logging.getLogger("toaster")
@@ -372,11 +373,37 @@ class Build(models.Model):
372 build_name = models.CharField(max_length=100) 373 build_name = models.CharField(max_length=100)
373 bitbake_version = models.CharField(max_length=50) 374 bitbake_version = models.CharField(max_length=50)
374 375
376 @staticmethod
377 def get_recent(project=None):
378 """
379 Return recent builds as a list; if project is set, only return
380 builds for that project
381 """
382
383 builds = Build.objects.all()
384
385 if project:
386 builds = builds.filter(project=project)
387
388 finished_criteria = Q(outcome=Build.SUCCEEDED) | Q(outcome=Build.FAILED)
389
390 recent_builds = list(itertools.chain(
391 builds.filter(outcome=Build.IN_PROGRESS).order_by("-started_on"),
392 builds.filter(finished_criteria).order_by("-completed_on")[:3]
393 ))
394
395 # add percentage done property to each build; this is used
396 # to show build progress in mrb_section.html
397 for build in recent_builds:
398 build.percentDone = build.completeper()
399
400 return recent_builds
401
375 def completeper(self): 402 def completeper(self):
376 tf = Task.objects.filter(build = self) 403 tf = Task.objects.filter(build = self)
377 tfc = tf.count() 404 tfc = tf.count()
378 if tfc > 0: 405 if tfc > 0:
379 completeper = tf.exclude(order__isnull=True).count()*100/tf.count() 406 completeper = tf.exclude(order__isnull=True).count()*100/tfc
380 else: 407 else:
381 completeper = 0 408 completeper = 0
382 return completeper 409 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
28from django.core.urlresolvers import reverse, resolve 28from django.core.urlresolvers import reverse, resolve
29from django.http import HttpResponse 29from django.http import HttpResponse
30from django.views.generic import TemplateView 30from django.views.generic import TemplateView
31import itertools
32 31
33from toastergui.tablefilter import TableFilter 32from toastergui.tablefilter import TableFilter
34from toastergui.tablefilter import TableFilterActionToggle 33from toastergui.tablefilter import TableFilterActionToggle
@@ -1060,17 +1059,9 @@ class BuildsTable(ToasterTable):
1060 def get_context_data(self, **kwargs): 1059 def get_context_data(self, **kwargs):
1061 context = super(BuildsTable, self).get_context_data(**kwargs) 1060 context = super(BuildsTable, self).get_context_data(**kwargs)
1062 1061
1063 # for the latest builds section 1062 # should be set in subclasses
1064 builds = self.get_builds() 1063 context['mru'] = []
1065 1064
1066 finished_criteria = Q(outcome=Build.SUCCEEDED) | Q(outcome=Build.FAILED)
1067
1068 latest_builds = itertools.chain(
1069 builds.filter(outcome=Build.IN_PROGRESS).order_by("-started_on"),
1070 builds.filter(finished_criteria).order_by("-completed_on")[:3]
1071 )
1072
1073 context['mru'] = list(latest_builds)
1074 context['mrb_type'] = self.mrb_type 1065 context['mrb_type'] = self.mrb_type
1075 1066
1076 return context 1067 return context
@@ -1481,6 +1472,12 @@ class AllBuildsTable(BuildsTable):
1481 static_data_name='project', 1472 static_data_name='project',
1482 static_data_template=project_template) 1473 static_data_template=project_template)
1483 1474
1475 def get_context_data(self, **kwargs):
1476 """ Get all builds for the recent builds area """
1477 context = super(AllBuildsTable, self).get_context_data(**kwargs)
1478 context['mru'] = Build.get_recent()
1479 return context
1480
1484class ProjectBuildsTable(BuildsTable): 1481class ProjectBuildsTable(BuildsTable):
1485 """ 1482 """
1486 Builds page for a single project; a BuildsTable, with the queryset 1483 Builds page for a single project; a BuildsTable, with the queryset
@@ -1521,18 +1518,16 @@ class ProjectBuildsTable(BuildsTable):
1521 1518
1522 def get_context_data(self, **kwargs): 1519 def get_context_data(self, **kwargs):
1523 """ 1520 """
1521 Get recent builds for this project, and the project itself
1522
1524 NOTE: self.project_id must be set before calling super(), 1523 NOTE: self.project_id must be set before calling super(),
1525 as it's used in get_context_data() 1524 as it's used in get_context_data()
1526 """ 1525 """
1527 self.project_id = kwargs['pid'] 1526 self.project_id = kwargs['pid']
1528
1529 context = super(ProjectBuildsTable, self).get_context_data(**kwargs) 1527 context = super(ProjectBuildsTable, self).get_context_data(**kwargs)
1530 context['project'] = Project.objects.get(pk=self.project_id)
1531
1532 return context
1533
1534 def get_builds(self):
1535 """ override: only return builds for the relevant project """
1536 1528
1537 project = Project.objects.get(pk=self.project_id) 1529 project = Project.objects.get(pk=self.project_id)
1538 return Build.objects.filter(project=project) 1530 context['mru'] = Build.get_recent(project)
1531 context['project'] = project
1532
1533 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(){
165 progressTimer = window.setInterval(function() { 165 progressTimer = window.setInterval(function() {
166 libtoaster.getProjectInfo(libtoaster.ctx.projectPageUrl, 166 libtoaster.getProjectInfo(libtoaster.ctx.projectPageUrl,
167 function(prjInfo){ 167 function(prjInfo){
168
169 /* These two are needed because a build can be 100% and still 168 /* These two are needed because a build can be 100% and still
170 * in progress due to the fact that the % done is updated at the 169 * in progress due to the fact that the % done is updated at the
171 * start of a task so it can be doing the last task at 100% 170 * start of a task so it can be doing the last task at 100%
@@ -176,18 +175,18 @@ $(document).ready(function(){
176 for (var i in prjInfo.builds){ 175 for (var i in prjInfo.builds){
177 var build = prjInfo.builds[i]; 176 var build = prjInfo.builds[i];
178 177
179 if (build.status === "In Progress" || 178 if (build.outcome === "In Progress" ||
180 $(".progress .bar").length > 0){ 179 $(".progress .bar").length > 0){
181 /* Update the build progress */ 180 /* Update the build progress */
182 var percentDone; 181 var percentDone;
183 182
184 if (build.status !== "In Progress"){ 183 if (build.outcome !== "In Progress"){
185 /* We have to ignore the value when it's Succeeded because it 184 /* We have to ignore the value when it's Succeeded because it
186 * goes back to 0 185 * goes back to 0
187 */ 186 */
188 percentDone = 100; 187 percentDone = 100;
189 } else { 188 } else {
190 percentDone = build.build[0].completeper; 189 percentDone = build.percentDone;
191 inProgress++; 190 inProgress++;
192 } 191 }
193 192
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:
2008 "completedbuilds": Build.objects.exclude(outcome = Build.IN_PROGRESS).filter(project_id = pid), 2008 "completedbuilds": Build.objects.exclude(outcome = Build.IN_PROGRESS).filter(project_id = pid),
2009 "prj" : {"name": prj.name, }, 2009 "prj" : {"name": prj.name, },
2010 "buildrequests" : prj.build_set.filter(outcome=Build.IN_PROGRESS), 2010 "buildrequests" : prj.build_set.filter(outcome=Build.IN_PROGRESS),
2011 #"builds" : _project_recent_build_list(prj), 2011 "builds" : Build.get_recent(prj),
2012 "layers" : map(lambda x: { 2012 "layers" : map(lambda x: {
2013 "id": x.layercommit.pk, 2013 "id": x.layercommit.pk,
2014 "orderid": x.pk, 2014 "orderid": x.pk,