From fe2e53ba30ba679c038bd5b48b9a91a41af4c49e Mon Sep 17 00:00:00 2001 From: Alexandru DAMIAN Date: Wed, 27 Aug 2014 17:24:42 +0100 Subject: bitbake: toaster: create Build methods for calculating progress and ETA We move the code to calculate build progress as percent and the ETA of the build to the model, so that they can be reused across different pages. (Bitbake rev: c2ced09e7ea4a1762d2788bb12a761734d20fd8e) Signed-off-by: Alexandru DAMIAN Signed-off-by: Richard Purdie --- bitbake/lib/toaster/orm/models.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'bitbake/lib/toaster/orm/models.py') diff --git a/bitbake/lib/toaster/orm/models.py b/bitbake/lib/toaster/orm/models.py index 5a6dcd72f6..bb921fc98e 100644 --- a/bitbake/lib/toaster/orm/models.py +++ b/bitbake/lib/toaster/orm/models.py @@ -120,6 +120,24 @@ class Build(models.Model): build_name = models.CharField(max_length=100) bitbake_version = models.CharField(max_length=50) + 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() + else: + completeper = 0 + return completeper + + def eta(self): + from django.utils import timezone + eta = 0 + completeper = self.completeper() + if self.completeper() > 0: + eta = timezone.now() + ((timezone.now() - self.started_on)*(100-completeper)/completeper) + return eta + + def get_sorted_target_list(self): tgts = Target.objects.filter(build_id = self.id).order_by( 'target' ); return( tgts ); -- cgit v1.2.3-54-g00ecf