diff options
author | Alexandru DAMIAN <alexandru.damian@intel.com> | 2015-06-17 17:30:34 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-06-26 09:27:32 +0100 |
commit | 70c4eb8d3acaad267ee943ebfba793f9cc1c5ee6 (patch) | |
tree | 416f9dcf9c16014e1fc2b975a1de01b286847e25 /bitbake/lib/toaster/orm/models.py | |
parent | 287b49a35b3f06b302ee199ed4b2d123f1aae58c (diff) | |
download | poky-70c4eb8d3acaad267ee943ebfba793f9cc1c5ee6.tar.gz |
bitbake: toaster: refactor build model
We remove the "timespent", "errors_no" and "warnings_no" fields
in favor of computing the needed values at runtime. This prevents
inconsistencies in the UI.
Also removeing all references to BuildRequests from the interface -
all build details now display in the build dashboard.
Minor fixes related to data logging.
(Bitbake rev: 44f37394ed3e4ca02f940be172fe4395b0ee0f7d)
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/models.py')
-rw-r--r-- | bitbake/lib/toaster/orm/models.py | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/bitbake/lib/toaster/orm/models.py b/bitbake/lib/toaster/orm/models.py index e93629b7ba..077c94d818 100644 --- a/bitbake/lib/toaster/orm/models.py +++ b/bitbake/lib/toaster/orm/models.py | |||
@@ -147,7 +147,7 @@ class Project(models.Model): | |||
147 | if (-1 == build_id): | 147 | if (-1 == build_id): |
148 | return( 0 ) | 148 | return( 0 ) |
149 | try: | 149 | try: |
150 | return Build.objects.filter(id = build_id)[ 0 ].errors_no | 150 | return Build.objects.filter(id = build_id)[ 0 ].errors.count() |
151 | except (Build.DoesNotExist,IndexError): | 151 | except (Build.DoesNotExist,IndexError): |
152 | return( "not_found" ) | 152 | return( "not_found" ) |
153 | 153 | ||
@@ -156,7 +156,7 @@ class Project(models.Model): | |||
156 | if (-1 == build_id): | 156 | if (-1 == build_id): |
157 | return( 0 ) | 157 | return( 0 ) |
158 | try: | 158 | try: |
159 | return Build.objects.filter(id = build_id)[ 0 ].warnings_no | 159 | return Build.objects.filter(id = build_id)[ 0 ].warnings.count() |
160 | except (Build.DoesNotExist,IndexError): | 160 | except (Build.DoesNotExist,IndexError): |
161 | return( "not_found" ) | 161 | return( "not_found" ) |
162 | 162 | ||
@@ -248,10 +248,7 @@ class Build(models.Model): | |||
248 | distro_version = models.CharField(max_length=100) | 248 | distro_version = models.CharField(max_length=100) |
249 | started_on = models.DateTimeField() | 249 | started_on = models.DateTimeField() |
250 | completed_on = models.DateTimeField() | 250 | completed_on = models.DateTimeField() |
251 | timespent = models.IntegerField(default=0) | ||
252 | outcome = models.IntegerField(choices=BUILD_OUTCOME, default=IN_PROGRESS) | 251 | outcome = models.IntegerField(choices=BUILD_OUTCOME, default=IN_PROGRESS) |
253 | errors_no = models.IntegerField(default=0) | ||
254 | warnings_no = models.IntegerField(default=0) | ||
255 | cooker_log_path = models.CharField(max_length=500) | 252 | cooker_log_path = models.CharField(max_length=500) |
256 | build_name = models.CharField(max_length=100) | 253 | build_name = models.CharField(max_length=100) |
257 | bitbake_version = models.CharField(max_length=50) | 254 | bitbake_version = models.CharField(max_length=50) |
@@ -281,6 +278,17 @@ class Build(models.Model): | |||
281 | def toaster_exceptions(self): | 278 | def toaster_exceptions(self): |
282 | return self.logmessage_set.filter(level=LogMessage.EXCEPTION) | 279 | return self.logmessage_set.filter(level=LogMessage.EXCEPTION) |
283 | 280 | ||
281 | @property | ||
282 | def errors(self): | ||
283 | return (self.logmessage_set.filter(level=LogMessage.ERROR)|self.logmessage_set.filter(level=LogMessage.EXCEPTION)) | ||
284 | |||
285 | @property | ||
286 | def warnings(self): | ||
287 | return self.logmessage_set.filter(level=LogMessage.WARNING) | ||
288 | |||
289 | @property | ||
290 | def timespent_seconds(self): | ||
291 | return (self.completed_on - self.started_on).total_seconds() | ||
284 | 292 | ||
285 | def get_current_status(self): | 293 | def get_current_status(self): |
286 | from bldcontrol.models import BuildRequest | 294 | from bldcontrol.models import BuildRequest |
@@ -298,7 +306,6 @@ class BuildArtifact(models.Model): | |||
298 | file_name = models.FilePathField() | 306 | file_name = models.FilePathField() |
299 | file_size = models.IntegerField() | 307 | file_size = models.IntegerField() |
300 | 308 | ||
301 | |||
302 | def get_local_file_name(self): | 309 | def get_local_file_name(self): |
303 | try: | 310 | try: |
304 | deploydir = Variable.objects.get(build = self.build, variable_name="DEPLOY_DIR").variable_value | 311 | deploydir = Variable.objects.get(build = self.build, variable_name="DEPLOY_DIR").variable_value |