All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Aníbal Limón" <anibal.limon@linux.intel.com>
To: yocto@yoctoproject.org
Cc: belen.barros.pena@linux.intel.com
Subject: [[PATCH][error-report-web] 8/8] Post/{models, views}.py: Add FAILURE field on BuildFailure model
Date: Mon, 13 Jun 2016 18:32:16 -0500	[thread overview]
Message-ID: <1465860736-26581-9-git-send-email-anibal.limon@linux.intel.com> (raw)
In-Reply-To: <1465860736-26581-1-git-send-email-anibal.limon@linux.intel.com>

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]

Signed-off-by: Aníbal Limón <anibal.limon@linux.intel.com>
---
 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

diff --git a/Post/migrations/0006_buildfailure_failure.py b/Post/migrations/0006_buildfailure_failure.py
new file mode 100644
index 0000000..b3e30bf
--- /dev/null
+++ b/Post/migrations/0006_buildfailure_failure.py
@@ -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)
+    ]
diff --git a/Post/models.py b/Post/models.py
index bec2abd..07694fe 100644
--- a/Post/models.py
+++ b/Post/models.py
@@ -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:
diff --git a/Post/parser.py b/Post/parser.py
index 295870f..2ef35c1 100644
--- a/Post/parser.py
+++ b/Post/parser.py
@@ -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()
 
diff --git a/Post/views.py b/Post/views.py
index 6b57977..41f0e2b 100644
--- a/Post/views.py
+++ b/Post/views.py
@@ -141,6 +141,7 @@ def search(request, mode=results_mode.LATEST, **kwargs):
         },
         {'name': 'Failure',
          'clclass': 'failure',
+         'field' : 'FAILURE',
          'disable_toggle' : True,
         },
         {'name': 'Machine',
diff --git a/templates/latest-errors.html b/templates/latest-errors.html
index 77a54af..a4418b5 100644
--- a/templates/latest-errors.html
+++ b/templates/latest-errors.html
@@ -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>
-- 
2.1.4



      parent reply	other threads:[~2016-06-13 23:31 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-13 23:32 [[PATCH][error-report-web] 0/8] Allow other type of errors and django 1.8 Aníbal Limón
2016-06-13 23:32 ` [[PATCH][error-report-web] 1/8] requirements.txt: Update requeriments for use 1.8 LTS Django version Aníbal Limón
2016-06-13 23:32 ` [[PATCH][error-report-web] 2/8] urls.py: RedirectView, fix warnings about change of default value in django 1.9 Aníbal Limón
2016-06-13 23:32 ` [[PATCH][error-report-web] 3/8] Post/models.py: Increase the TASK field length Aníbal Limón
2016-06-13 23:32 ` [[PATCH][error-report-web] 4/8] Post/migrations/0003_auto_20150603_0913.py: Replace tabs for spaces Aníbal Limón
2016-06-13 23:32 ` [[PATCH][error-report-web] 5/8] Post/models.py: Build model add support for Error type Aníbal Limón
2016-06-14 13:30   ` Michael Wood
2016-06-14 16:44     ` Aníbal Limón
2016-06-14 19:23       ` Aníbal Limón
2016-06-13 23:32 ` [[PATCH][error-report-web] 6/8] Post/{models, parser}.py: Add support for receive/store error_type Aníbal Limón
2016-06-13 23:32 ` [[PATCH][error-report-web] 7/8] views/templates: Add support for display different type of errors Aníbal Limón
2016-06-13 23:32 ` Aníbal Limón [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1465860736-26581-9-git-send-email-anibal.limon@linux.intel.com \
    --to=anibal.limon@linux.intel.com \
    --cc=belen.barros.pena@linux.intel.com \
    --cc=yocto@yoctoproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.