diff options
author | Elliot Smith <elliot.smith@intel.com> | 2016-01-18 14:23:55 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-02-10 13:29:20 +0000 |
commit | efbffe3c298d57af34324639f2208e35735758a9 (patch) | |
tree | 211cb0601b9b1ed6fe6ad220cb03818080a3d725 /bitbake/lib/toaster/orm/models.py | |
parent | b51478582f17bc9c43a92232e41246aec3e89f36 (diff) | |
download | poky-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/lib/toaster/orm/models.py')
-rw-r--r-- | bitbake/lib/toaster/orm/models.py | 29 |
1 files changed, 28 insertions, 1 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 | ||
32 | import os.path | 32 | import os.path |
33 | import re | 33 | import re |
34 | import itertools | ||
34 | 35 | ||
35 | import logging | 36 | import logging |
36 | logger = logging.getLogger("toaster") | 37 | logger = 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 |