Skip to contentSkip to conversation

0/8] Allow other type of errors and django 1.8

PATCH New Aníbal Limón 2 participants 12 messages Jun 13, 2016 – Jun 14, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 0/8] Allow other type of errors and django 1.8

The next patches enables support of django 1.8 LTS (two patches) and the other are for enable to display other type of errors not only task related ones based on design [1].

Also the changes could be reviewed at,

http://git.yoctoproject.org/cgit/cgit.cgi/error-report-web/log/?h=alimon/devel

[1] https://bugzilla.yoctoproject.org/attachment.cgi?id=3214

Aníbal Limón (8):
requirements.txt: Update requeriments for use 1.8 LTS Django version. urls.py: RedirectView, fix warnings about change of default value in

    django 1.9

Post/models.py: Increase the TASK field length Post/migrations/0003_auto_20150603_0913.py: Replace tabs for spaces Post/models.py: Build model add support for Error type. Post/{models,parser}.py: Add support for receive/store error_type. views/templates: Add support for display different type of errors Post/{models,views}.py: Add FAILURE field on BuildFailure model

 Post/migrations/0003_auto_20150603_0913.py   |  6 +++---
 Post/migrations/0004_auto_20160530_1126.py   | 20 ++++++++++++++++++++
 Post/migrations/0005_build_error_type.py     | 19 +++++++++++++++++++
 Post/migrations/0006_buildfailure_failure.py | 28 ++++++++++++++++++++++++++++
 Post/models.py                               | 20 +++++++++++++++++++-
 Post/parser.py                               | 17 ++++++++++++++---
 Post/views.py                                | 17 ++++++-----------
 project/urls.py                              |  4 ++--
 requirements.txt                             |  2 +-
 templates/error-details.html                 | 13 ++++++++++++-
 templates/latest-errors.html                 | 16 ++++++++--------
 11 files changed, 132 insertions(+), 30 deletions(-)
 create mode 100644 Post/migrations/0004_auto_20160530_1126.py
 create mode 100644 Post/migrations/0005_build_error_type.py
 create mode 100644 Post/migrations/0006_buildfailure_failure.py
Signature · 1 line
2.1.4
#1 lore raw

PATCH 1/1 1/8] requirements.txt: Update requeriments for use 1.8 LTS Django version.

[YOCTO #9733]

---
 requirements.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
requirements.txt +1 -1
index 9521321..909d054 100644
@@ -1,2 +1,2 @@
-Django==1.7.3
+Django<1.9
 python-Levenshtein==0.12.0
Signature · 1 line
2.1.4
#2 lore raw

PATCH 1/1 2/8] urls.py: RedirectView, fix warnings about change of default value in django 1.9

In reply to Aníbal Limón

RemovedInDjango19Warning: Default value of 'RedirectView.permanent' will change from True to False in Django 1.9. Set an explicit value to silence this warning.
url(r'^$', RedirectView.as_view(pattern_name="main")),

RemovedInDjango19Warning: Default value of 'RedirectView.permanent' will change from True to False in Django 1.9. Set an explicit value to silence this warning.
url(r'^Errors/Search/Args/$',
RedirectView.as_view(pattern_name="Post.views.search",query_string=True), {'mode':results_mode.SEARCH }),

[YOCTO #9733]

---
 project/urls.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
project/urls.py +2 -2
index 7b6f643..0e8f39c 100644
@@ -37,7 +37,7 @@ urlpatterns = patterns('',
     url(r'^(?i)ClientPost/JSON/$', 'Post.views.addData', { 'return_json' : True }),
     url(r'^(?i)Errors/$', 'Post.views.default', name="main"),
     url(r'^(?i)Statistics/$', TemplateView.as_view(template_name="home.html"), name = "statistics"),
-    url(r'^$', RedirectView.as_view(pattern_name="main")),
+    url(r'^$', RedirectView.as_view(pattern_name="main", permanent=True)),
     # Url for backwards compatibility with old search links
-    url(r'^Errors/Search/Args/$', RedirectView.as_view(pattern_name="Post.views.search",query_string=True), {'mode':results_mode.SEARCH }),
+    url(r'^Errors/Search/Args/$', RedirectView.as_view(pattern_name="Post.views.search",query_string=True,permanent=True), {'mode':results_mode.SEARCH }),
 )
Signature · 1 line
2.1.4
#3 lore raw

PATCH 1/1 3/8] Post/models.py: Increase the TASK field length

In reply to Aníbal Limón

Now bitbake exception/errors can be published into ERW so TASK in bitbake is the command line executed.

[YOCTO #7583]

---
 Post/migrations/0004_auto_20160530_1126.py | 20 ++++++++++++++++++++
 Post/models.py                             |  2 +-
 2 files changed, 21 insertions(+), 1 deletion(-)
 create mode 100644 Post/migrations/0004_auto_20160530_1126.py
Post/migrations/0004_auto_20160530_1126.py new file +20 -0
new file mode 100644
index 0000000..936454d
@@ -0,0 +1,20 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import models, migrations
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('Post', '0003_auto_20150603_0913'),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name='buildfailure',
+            name='TASK',
+            field=models.CharField(max_length=1024),
+            preserve_default=True,
+        ),
+    ]
Post/models.py +1 -1
index d1bae38..84f8abf 100644
@@ -27,7 +27,7 @@ class Build(models.Model):
     LINK_BACK = models.TextField(max_length=300, blank=True, null=True)
 
 class BuildFailure(models.Model):
-    TASK = models.CharField(max_length=200)
+    TASK = models.CharField(max_length=1024)
     RECIPE= models.CharField(max_length=250)
     RECIPE_VERSION = models.CharField(max_length=200)
     ERROR_DETAILS = models.TextField(max_length=int(settings.MAX_UPLOAD_SIZE))
Signature · 1 line
2.1.4
#4 lore raw

PATCH 1/1 4/8] Post/migrations/0003_auto_20150603_0913.py: Replace tabs for spaces

In reply to Aníbal Limón

When try to migrate using python3 it raises an exception because found tabs inside the migration.

---
 Post/migrations/0003_auto_20150603_0913.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
Post/migrations/0003_auto_20150603_0913.py +3 -3
index 321f09f..f936883 100644
@@ -34,9 +34,9 @@ def add_lev_distance_data(apps, schema_editor):
     while offset < count:
         objs = BuildFailure.objects.all()[offset : offset + pagesize]
         for f in objs:
-	    if f.LEV_DISTANCE is None:
-		f.LEV_DISTANCE = calc_lev_distance(f)
-	        f.save()
+            if f.LEV_DISTANCE is None:
+                f.LEV_DISTANCE = calc_lev_distance(f)
+                f.save()
 
         del objs
         offset = offset + pagesize
Signature · 1 line
2.1.4
#5 lore raw

PATCH 1/1 5/8] Post/models.py: Build model add support for Error type.

In reply to Aníbal Limón

In order to support other errors not only Recipe ones adds a ERROR_TYPE field to the Build model defaults to "Recipe".

Add a class for store BuildErrorType currently supported Recipe, Core, Bitbake selftest and OE selftest.

[YOCTO #7583]

---
 Post/migrations/0005_build_error_type.py | 19 +++++++++++++++++++
 Post/models.py                           |  7 +++++++
 2 files changed, 26 insertions(+)
 create mode 100644 Post/migrations/0005_build_error_type.py
Post/migrations/0005_build_error_type.py new file +19 -0
new file mode 100644
index 0000000..96cdf8c
@@ -0,0 +1,19 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('Post', '0004_auto_20160530_1126'),
+    ]
+
+    operations = [
+        migrations.AddField(
+            model_name='build',
+            name='ERROR_TYPE',
+            field=models.CharField(default=b'Recipe', max_length=64),
+        ),
+    ]
Post/models.py +7 -0
index 84f8abf..f8d9916 100644
@@ -11,6 +11,12 @@ from datetime import datetime
 
 import Levenshtein
 
+class BuildErrorType(object):
+    RECIPE = "Recipe"
+    BITBAKE_CORE = "Core"
+    BITBAKE_SELFTEST = "Bitbake selftest"
+    OE_SELFTEST = "OE selftest"
+
 # Create your models here.
 class Build(models.Model):
     DATE = models.DateTimeField('Submit date', blank=True, null=True)
@@ -25,6 +31,7 @@ class Build(models.Model):
     NAME = models.CharField(max_length=50)
     EMAIL = models.CharField(max_length=50)
     LINK_BACK = models.TextField(max_length=300, blank=True, null=True)
+    ERROR_TYPE = models.CharField(max_length=64, default=BuildErrorType.RECIPE)
 
 class BuildFailure(models.Model):
     TASK = models.CharField(max_length=1024)
Signature · 1 line
2.1.4
#6 lore raw

Re: [[PATCH][error-report-web] 5/8] Post/models.py: Build model add support for Error type.

Quoted 58 lines · Aníbal Limón

In order to support other errors not only Recipe ones adds a ERROR_TYPE field to the Build model defaults to "Recipe".

Add a class for store BuildErrorType currently supported Recipe, Core, Bitbake selftest and OE selftest.

[YOCTO #7583]

---
  Post/migrations/0005_build_error_type.py | 19 +++++++++++++++++++
  Post/models.py                           |  7 +++++++
  2 files changed, 26 insertions(+)

create mode 100644 Post/migrations/0005_build_error_type.py

Post/migrations/0005_build_error_type.py new file +19 -0
new file mode 100644
index 0000000..96cdf8c
@@ -0,0 +1,19 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('Post', '0004_auto_20160530_1126'),
+    ]
+
+    operations = [
+        migrations.AddField(
+            model_name='build',
+            name='ERROR_TYPE',
+            field=models.CharField(default=b'Recipe', max_length=64),
+        ),
+    ]
Post/models.py +6 -0
index 84f8abf..f8d9916 100644
@@ -11,6 +11,12 @@ from datetime import datetime
 
  import Levenshtein
 
+class BuildErrorType(object):
+    RECIPE = "Recipe"
+    BITBAKE_CORE = "Core"
+    BITBAKE_SELFTEST = "Bitbake selftest"
+    OE_SELFTEST = "OE selftest"
+
  # Create your models here.
  class Build(models.Model):
      DATE = models.DateTimeField('Submit date', blank=True, null=True)

Post/models.py class Build(models.Model): · line 37

Quoted 7 lines
Post/models.py +1 -0
@@ -25,6 +31,7 @@ class Build(models.Model):
      NAME = models.CharField(max_length=50)
      EMAIL = models.CharField(max_length=50)
      LINK_BACK = models.TextField(max_length=300, blank=True, null=True)
+    ERROR_TYPE = models.CharField(max_length=64, default=BuildErrorType.RECIPE)
 
  class BuildFailure(models.Model):
      TASK = models.CharField(max_length=1024)

Thanks for the patches.

Ideally we wouldn't use a char field here as if the type string ever changed the database could end up with multiple versions of the type strings depending on when the type was saved, it would be possible to handle that with migrations but it would be pretty messy. It also allows any arbitrary chars which we probably don't want if it's something we're going to be filtering on. Here is an example from Toaster on how it can be done with the choices option and an enum style.

|OUTCOME_NA = -1 OUTCOME_SUCCESS = 0 OUTCOME_COVERED = 1 OUTCOME_CACHED = 2 OUTCOME_PREBUILT = 3 OUTCOME_FAILED = 4 OUTCOME_EMPTY = 5 TASK_OUTCOME = ( (OUTCOME_NA, 'Not Available'), (OUTCOME_SUCCESS, 'Succeeded'), (OUTCOME_COVERED, 'Covered'), (OUTCOME_CACHED, 'Cached'), (OUTCOME_PREBUILT, 'Prebuilt'), (OUTCOME_FAILED, 'Failed'), (OUTCOME_EMPTY, 'Empty'), ) ||outcome = models.IntegerField(choices=TASK_OUTCOME, default=OUTCOME_NA)|

Michael

#7 lore raw

Re: [[PATCH][error-report-web] 5/8] Post/models.py: Build model add support for Error type.

Quoted 76 lines · Michael Wood
Quoted 57 lines · Aníbal Limón

In order to support other errors not only Recipe ones adds a ERROR_TYPE field to the Build model defaults to "Recipe".

Add a class for store BuildErrorType currently supported Recipe, Core, Bitbake selftest and OE selftest.

[YOCTO #7583]

---
  Post/migrations/0005_build_error_type.py | 19 +++++++++++++++++++
  Post/models.py                           |  7 +++++++
  2 files changed, 26 insertions(+)

create mode 100644 Post/migrations/0005_build_error_type.py

Post/migrations/0005_build_error_type.py new file +19 -0
new file mode 100644
index 0000000..96cdf8c
@@ -0,0 +1,19 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('Post', '0004_auto_20160530_1126'),
+    ]
+
+    operations = [
+        migrations.AddField(
+            model_name='build',
+            name='ERROR_TYPE',
+            field=models.CharField(default=b'Recipe', max_length=64),
+        ),
+    ]
Post/models.py +5 -0
index 84f8abf..f8d9916 100644
@@ -11,6 +11,12 @@ from datetime import datetime
    import Levenshtein
  +class BuildErrorType(object):
+    RECIPE = "Recipe"
+    BITBAKE_CORE = "Core"
+    BITBAKE_SELFTEST = "Bitbake selftest"
+    OE_SELFTEST = "OE selftest"
+
  # Create your models here.
  class Build(models.Model):
      DATE = models.DateTimeField('Submit date', blank=True, null=True)

Post/models.py class Build(models.Model): · line 37

Quoted 7 lines
Post/models.py +1 -0
@@ -25,6 +31,7 @@ class Build(models.Model):
      NAME = models.CharField(max_length=50)
      EMAIL = models.CharField(max_length=50)
      LINK_BACK = models.TextField(max_length=300, blank=True, null=True)
+    ERROR_TYPE = models.CharField(max_length=64,
 default=BuildErrorType.RECIPE)
    class BuildFailure(models.Model):
      TASK = models.CharField(max_length=1024)

Thanks for the patches.

Ideally we wouldn't use a char field here as if the type string ever changed the database could end up with multiple versions of the type strings depending on when the type was saved, it would be possible to handle that with migrations but it would be pretty messy. It also allows any arbitrary chars which we probably don't want if it's something we're going to be filtering on. Here is an example from Toaster on how it can be done with the choices option and an enum style.

Quoted 8 lines

|OUTCOME_NA = -1 OUTCOME_SUCCESS = 0 OUTCOME_COVERED = 1 OUTCOME_CACHED = 2 OUTCOME_PREBUILT = 3 OUTCOME_FAILED = 4 OUTCOME_EMPTY = 5 TASK_OUTCOME = ( (OUTCOME_NA, 'Not Available'), (OUTCOME_SUCCESS, 'Succeeded'), (OUTCOME_COVERED, 'Covered'), (OUTCOME_CACHED, 'Cached'), (OUTCOME_PREBUILT, 'Prebuilt'), (OUTCOME_FAILED, 'Failed'), (OUTCOME_EMPTY, 'Empty'), ) ||outcome = models.IntegerField(choices=TASK_OUTCOME, default=OUTCOME_NA)|

Thanks for the feedback, i'll change to use choices instead of char values.

alimon

Quoted 4 lines

Michael

#8 lore raw

Re: [[PATCH][error-report-web] 5/8] Post/models.py: Build model add support for Error type.

Quoted 88 lines · Aníbal Limón
Quoted 76 lines · Michael Wood
Quoted 57 lines · Aníbal Limón

In order to support other errors not only Recipe ones adds a ERROR_TYPE field to the Build model defaults to "Recipe".

Add a class for store BuildErrorType currently supported Recipe, Core, Bitbake selftest and OE selftest.

[YOCTO #7583]

---
  Post/migrations/0005_build_error_type.py | 19 +++++++++++++++++++
  Post/models.py                           |  7 +++++++
  2 files changed, 26 insertions(+)

create mode 100644 Post/migrations/0005_build_error_type.py

Post/migrations/0005_build_error_type.py new file +19 -0
new file mode 100644
index 0000000..96cdf8c
@@ -0,0 +1,19 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('Post', '0004_auto_20160530_1126'),
+    ]
+
+    operations = [
+        migrations.AddField(
+            model_name='build',
+            name='ERROR_TYPE',
+            field=models.CharField(default=b'Recipe', max_length=64),
+        ),
+    ]
Post/models.py +5 -0
index 84f8abf..f8d9916 100644
@@ -11,6 +11,12 @@ from datetime import datetime
    import Levenshtein
  +class BuildErrorType(object):
+    RECIPE = "Recipe"
+    BITBAKE_CORE = "Core"
+    BITBAKE_SELFTEST = "Bitbake selftest"
+    OE_SELFTEST = "OE selftest"
+
  # Create your models here.
  class Build(models.Model):
      DATE = models.DateTimeField('Submit date', blank=True, null=True)

Post/models.py class Build(models.Model): · line 37

Quoted 7 lines
Post/models.py +1 -0
@@ -25,6 +31,7 @@ class Build(models.Model):
      NAME = models.CharField(max_length=50)
      EMAIL = models.CharField(max_length=50)
      LINK_BACK = models.TextField(max_length=300, blank=True, null=True)
+    ERROR_TYPE = models.CharField(max_length=64,
 default=BuildErrorType.RECIPE)
    class BuildFailure(models.Model):
      TASK = models.CharField(max_length=1024)

Thanks for the patches.

Ideally we wouldn't use a char field here as if the type string ever changed the database could end up with multiple versions of the type strings depending on when the type was saved, it would be possible to handle that with migrations but it would be pretty messy. It also allows any arbitrary chars which we probably don't want if it's something we're going to be filtering on. Here is an example from Toaster on how it can be done with the choices option and an enum style.

Quoted 8 lines

|OUTCOME_NA = -1 OUTCOME_SUCCESS = 0 OUTCOME_COVERED = 1 OUTCOME_CACHED = 2 OUTCOME_PREBUILT = 3 OUTCOME_FAILED = 4 OUTCOME_EMPTY = 5 TASK_OUTCOME = ( (OUTCOME_NA, 'Not Available'), (OUTCOME_SUCCESS, 'Succeeded'), (OUTCOME_COVERED, 'Covered'), (OUTCOME_CACHED, 'Cached'), (OUTCOME_PREBUILT, 'Prebuilt'), (OUTCOME_FAILED, 'Failed'), (OUTCOME_EMPTY, 'Empty'), ) ||outcome = models.IntegerField(choices=TASK_OUTCOME, default=OUTCOME_NA)|

Quoted 3 lines

Thanks for the feedback, i'll change to use choices instead of char values.

alimon

I made the change now is at contrib branch,

http://git.yoctoproject.org/cgit/cgit.cgi/error-report-web/log/?h=alimon/devel

alimon

Quoted 8 lines
Quoted 5 lines

Michael

#9 lore raw

PATCH 1/1 6/8] Post/{models, parser}.py: Add support for receive/store error_type.

In reply to Aníbal Limón

For compatibility reasons if error_type isn't specified in the JSON payload use BuildErrorType.RECIPE by default.

[YOCTO #7584]

---
 Post/models.py | 10 ++++++++++
 Post/parser.py | 11 +++++++++--
 2 files changed, 19 insertions(+), 2 deletions(-)
Post/models.py +10 -0
index f8d9916..bec2abd 100644
@@ -17,6 +17,16 @@ class BuildErrorType(object):
     BITBAKE_SELFTEST = "Bitbake selftest"
     OE_SELFTEST = "OE selftest"
 
+    @staticmethod
+    def is_supported(error_type):
+        if error_type == BuildErrorType.RECIPE or \
+                error_type == BuildErrorType.BITBAKE_CORE or \
+                error_type == BuildErrorType.BITBAKE_SELFTEST or \
+                error_type == BuildErrorType.OE_SELFTEST:
+            return True
+
+        return False
+
 # Create your models here.
 class Build(models.Model):
     DATE = models.DateTimeField('Submit date', blank=True, null=True)
Post/parser.py +9 -2
index 599afde..295870f 100644
@@ -8,7 +8,7 @@
 # Licensed under the MIT license, see COPYING.MIT for details
 
 import json, re
-from Post.models import Build, BuildFailure
+from Post.models import Build, BuildFailure, BuildErrorType
 from django.conf import settings
 from django.utils import timezone
 from django.core.urlresolvers import reverse
@@ -40,6 +40,7 @@ class Parser:
         if self.contains_tags(jsondata) == True:
             return  { 'error' : 'Invalid characters in json' }
 
+        error_desc = ""
         b = Build.objects.create()
         try:
             b.MACHINE = str(jsondata['machine'])
@@ -53,6 +54,12 @@ class Parser:
             b.EMAIL = str(jsondata['email'])
             b.LINK_BACK = jsondata.get("link_back", None)
 
+            error_type = jsondata.get("error_type", None) or BuildErrorType.RECIPE
+            if not BuildErrorType.is_supported(error_type):
+                error_desc = "Unsupported error_type %s" % error_type
+                raise ""
+            b.ERROR_TYPE = error_type
+
             # Extract the branch and commit
             g = re.match(r'(.*): (.*)', jsondata['branch_commit'])
 
@@ -68,7 +75,7 @@ class Parser:
             b.save()
             failures = jsondata['failures']
         except:
-            return { 'error' : "Problem reading json payload" }
+            return { 'error' : "Problem reading json payload, %s" % error_desc }
 
         for fail in failures:
             if len(fail) > int(settings.MAX_UPLOAD_SIZE):
Signature · 1 line
2.1.4
#10 lore raw

PATCH 1/1 7/8] views/templates: Add support for display different type of errors

In reply to Aníbal Limón

Now we have a set of different type of errors not only Recipe ones this change enable support for display it based on design did by Belen Barros [1].

[YOCTO #7583]

[1] https://bugzilla.yoctoproject.org/attachment.cgi?id=3214

---
 Post/views.py                | 16 +++++-----------
 templates/error-details.html | 13 ++++++++++++-
 templates/latest-errors.html | 19 +++++++++++--------
 3 files changed, 28 insertions(+), 20 deletions(-)
Post/views.py +5 -11
index 0455baa..6b57977 100644
@@ -134,18 +134,13 @@ def search(request, mode=results_mode.LATEST, **kwargs):
          'field' : 'BUILD__DATE',
          'disable_toggle' : True,
         },
-        {'name': 'Recipe',
-         'clclass' : 'recipe',
-         'field' : 'RECIPE',
+        {'name': 'Error type',
+         'clclass' : 'error_type',
+         'field' : 'BUILD__ERROR_TYPE',
          'disable_toggle' : True,
         },
-        {'name': 'Recipe version',
-         'clclass': 'recipe_version',
-         'field' : 'RECIPE_VERSION',
-        },
-        {'name': 'Task',
-         'clclass': 'task',
-         'field' : 'TASK',
+        {'name': 'Failure',
+         'clclass': 'failure',
          'disable_toggle' : True,
         },
         {'name': 'Machine',
@@ -156,7 +151,6 @@ def search(request, mode=results_mode.LATEST, **kwargs):
         {'name': 'Distro',
          'clclass': 'distro',
          'field': 'BUILD__DISTRO',
-         'disable_toggle' : True,
         },
         {'name': 'Build system',
          'clclass': 'build_sys',
templates/error-details.html +12 -1
index 62ec75f..e5bf758 100644
@@ -9,7 +9,11 @@
     <a class="btn pull-left back-btn" style="margin-top:7px;" href="#">
       <i class="icon-arrow-left"></i>
     </a>
-    <h1 style="margin-left:60px;">{{detail.RECIPE}}-{{detail.RECIPE_VERSION}} {{detail.TASK}} </h1>
+    <h1 style="margin-left:60px;">
+        {% if detail.BUILD.ERROR_TYPE == "Recipe" %}
+        {{detail.RECIPE}}-{{detail.RECIPE_VERSION}}
+        {% endif %}
+        {{detail.TASK}} </h1>
   </div>
   <div class="row span8">
     <pre>{{detail.ERROR_DETAILS}}</pre>
@@ -20,12 +24,19 @@
       <dl class="dl-vertical">
         <dt>Submitted on:</dt>
         <dd>{{ detail.BUILD.DATE|date:"d/m/y H:i"}}</dd>
+        <dt>Error type:</dt>
+        <dd>{{ detail.BUILD.ERROR_TYPE }}</dd>
+        {% if detail.BUILD.ERROR_TYPE == "Recipe" %}
         <dt>Task:</dt>
         <dd>{{ detail.TASK }}</dd>
         <dt>Recipe:</dt>
         <dd>{{detail.RECIPE }} </dd>
         <dt>Recipe version:</dt>
         <dd>{{ detail.RECIPE_VERSION }}</dd>
+        {% else %}
+        <dt>Command:</dt>
+        <dd>{{ detail.TASK }}</dd>
+        {% endif %}
         <dt>Machine:</dt>
         <dd>{{ detail.BUILD.MACHINE }}</dd>
         <dt>Distro:</dt>
templates/latest-errors.html +11 -8
index 56f612a..77a54af 100644
@@ -127,18 +127,21 @@
               {% url "details" build_fail.id as details_url %}
               <tr class="data">
                 <td class="submitted_on"> <a href="{{details_url}}">{{ build_fail.BUILD.DATE|date:"d/m/y H:i"}}</a></td>
-                <td class="recipe"><a href="{{details_url}}">{{ build_fail.RECIPE }}</a>
-                  <a class="filter" href="#" data-filter="{{build_fail.RECIPE}}" data-type="recipe">
-                    <i class="icon-filter hover" title="Filter by {{build_fail.RECIPE}}"></i>
+
+                <td class="error_type"><a href="{{details_url}}">{{ build_fail.BUILD.ERROR_TYPE }}</a>
+                  <a class="filter" href="#" data-filter="{{build_fail.BUILD.ERROR_TYPE}}" data-type="error_type">
+                    <i class="icon-filter hover" title="Filter by {{build_fail.BUILD.ERROR_TYPE}}"></i>
                   </a>
                 </td>
-                <td class="recipe_version"><a href="{{details_url}}" {% if build_fail.RECIPE_VERSION|length > 13 %}class="tooltip-me" data-toggle="tooltip" title="{{ build_fail.RECIPE_VERSION }}"{%endif%}>{{ build_fail.RECIPE_VERSION|truncatechars:13 }}</a></td>
-                <td class="task"><a href="{{details_url}}">{{ build_fail.TASK }}</a>
-                  <a class="filter"  href="#" data-filter="{{build_fail.TASK}}" data-type="task">
-                    <i class="icon-filter hover" title="Filter by {{build_fail.TASK}}"></i>
-                  </a>
 
+                <td class="failure">
+                    <a href="{{details_url}}">
+                        {% if build_fail.BUILD.ERROR_TYPE == "Recipe" %}
+                        {{ build_fail.RECIPE }}:
+                        {% endif %}
+                        {{ build_fail.TASK }}</a>
                 </td>
+
                 <td class="machine"><a href="{{details_url}}">{{ build_fail.BUILD.MACHINE }}</a>
                   <a class="filter"  href="#" data-filter="{{build_fail.BUILD.MACHINE}}" data-type="machine">
                     <i class="icon-filter hover" title="Filter by {{build_fail.BUILD.MACHINE}}"></i>
Signature · 1 line
2.1.4
#11 lore raw

PATCH 1/1 8/8] Post/{models, views}.py: Add FAILURE field on BuildFailure model

In reply to Aníbal Limón

In order to support filters using django Paginator adds a FAILURE field by default contains "RECIPE: TASK" when ERROR_TYPE is Recipe instead contains only "TASK".

[YOCTO #7583]

---
 Post/migrations/0006_buildfailure_failure.py | 28 ++++++++++++++++++++++++++++
 Post/models.py                               |  1 +
 Post/parser.py                               |  6 +++++-
 Post/views.py                                |  1 +
 templates/latest-errors.html                 |  5 +----
 5 files changed, 36 insertions(+), 5 deletions(-)
 create mode 100644 Post/migrations/0006_buildfailure_failure.py
Post/migrations/0006_buildfailure_failure.py new file +28 -0
new file mode 100644
index 0000000..b3e30bf
@@ -0,0 +1,28 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+def populate_failure(apps, schema_editor):
+    model = apps.get_model("Post", "BuildFailure")
+    for build_failure in model.objects.all():
+        if build_failure.BUILD.ERROR_TYPE == "Recipe":
+            build_failure.FAILURE = "%s: %s" \
+                    (build_failure.RECIPE, build_failure.TASK)
+        else:
+            build_failure.FAILURE = build_failure.TASK
+        build_failure.save()
+
+class Migration(migrations.Migration):
+    dependencies = [
+        ('Post', '0005_build_error_type'),
+    ]
+
+    operations = [
+        migrations.AddField(
+            model_name='buildfailure',
+            name='FAILURE',
+            field=models.CharField(max_length=1024, blank=True),
+        ),
+        migrations.RunPython(populate_failure)
+    ]
Post/models.py +1 -0
index bec2abd..07694fe 100644
@@ -50,6 +50,7 @@ class BuildFailure(models.Model):
     ERROR_DETAILS = models.TextField(max_length=int(settings.MAX_UPLOAD_SIZE))
     BUILD = models.ForeignKey(Build)
     LEV_DISTANCE = models.IntegerField(blank=True, null=True)
+    FAILURE = models.CharField(max_length=1024, blank=True)
 
     def get_similar_fails(self):
         if self.LEV_DISTANCE is None:
Post/parser.py +5 -1
index 295870f..2ef35c1 100644
@@ -92,7 +92,11 @@ class Parser:
                 recipe = package
                 recipe_version = "unknown"
 
-            f = BuildFailure(TASK = str(fail['task']), RECIPE = recipe, RECIPE_VERSION = recipe_version, ERROR_DETAILS = fail['log'].encode('utf-8'), BUILD = b)
+            if b.ERROR_TYPE = "Recipe":
+                failure = "%s: %s" % (recipe, str(fail['task']))
+            else:
+                failure = str(fail['task'])
+            f = BuildFailure(TASK = str(fail['task']), RECIPE = recipe, RECIPE_VERSION = recipe_version, ERROR_DETAILS = fail['log'].encode('utf-8'), BUILD = b, FAILURE = failure)
 
             f.save()
 
Post/views.py +1 -0
index 6b57977..41f0e2b 100644
@@ -141,6 +141,7 @@ def search(request, mode=results_mode.LATEST, **kwargs):
         },
         {'name': 'Failure',
          'clclass': 'failure',
+         'field' : 'FAILURE',
          'disable_toggle' : True,
         },
         {'name': 'Machine',
templates/latest-errors.html +1 -4
index 77a54af..a4418b5 100644
@@ -136,10 +136,7 @@
 
                 <td class="failure">
                     <a href="{{details_url}}">
-                        {% if build_fail.BUILD.ERROR_TYPE == "Recipe" %}
-                        {{ build_fail.RECIPE }}:
-                        {% endif %}
-                        {{ build_fail.TASK }}</a>
+                        {{ build_fail.FAILURE }}</a>
                 </td>
 
                 <td class="machine"><a href="{{details_url}}">{{ build_fail.BUILD.MACHINE }}</a>
Signature · 1 line
2.1.4