diff options
author | Alexandru DAMIAN <alexandru.damian@intel.com> | 2014-08-27 17:24:42 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2014-08-29 13:56:50 +0100 |
commit | fe2e53ba30ba679c038bd5b48b9a91a41af4c49e (patch) | |
tree | 2a86f1fa56d21c7c712f8723485d5a1e386ecc24 /bitbake/lib/toaster/orm | |
parent | 69955c7b4218c51e1905c683757788af883a421b (diff) | |
download | poky-fe2e53ba30ba679c038bd5b48b9a91a41af4c49e.tar.gz |
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 <alexandru.damian@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/toaster/orm')
-rw-r--r-- | bitbake/lib/toaster/orm/models.py | 18 |
1 files changed, 18 insertions, 0 deletions
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): | |||
120 | build_name = models.CharField(max_length=100) | 120 | build_name = models.CharField(max_length=100) |
121 | bitbake_version = models.CharField(max_length=50) | 121 | bitbake_version = models.CharField(max_length=50) |
122 | 122 | ||
123 | def completeper(self): | ||
124 | tf = Task.objects.filter(build = self) | ||
125 | tfc = tf.count() | ||
126 | if tfc > 0: | ||
127 | completeper = tf.exclude(order__isnull=True).count()*100/tf.count() | ||
128 | else: | ||
129 | completeper = 0 | ||
130 | return completeper | ||
131 | |||
132 | def eta(self): | ||
133 | from django.utils import timezone | ||
134 | eta = 0 | ||
135 | completeper = self.completeper() | ||
136 | if self.completeper() > 0: | ||
137 | eta = timezone.now() + ((timezone.now() - self.started_on)*(100-completeper)/completeper) | ||
138 | return eta | ||
139 | |||
140 | |||
123 | def get_sorted_target_list(self): | 141 | def get_sorted_target_list(self): |
124 | tgts = Target.objects.filter(build_id = self.id).order_by( 'target' ); | 142 | tgts = Target.objects.filter(build_id = self.id).order_by( 'target' ); |
125 | return( tgts ); | 143 | return( tgts ); |