diff options
Diffstat (limited to 'bitbake/lib/toaster/toastergui/tables.py')
-rw-r--r-- | bitbake/lib/toaster/toastergui/tables.py | 40 |
1 files changed, 27 insertions, 13 deletions
diff --git a/bitbake/lib/toaster/toastergui/tables.py b/bitbake/lib/toaster/toastergui/tables.py index 14077e10ae..227973114c 100644 --- a/bitbake/lib/toaster/toastergui/tables.py +++ b/bitbake/lib/toaster/toastergui/tables.py | |||
@@ -23,7 +23,7 @@ from toastergui.widgets import ToasterTable | |||
23 | from orm.models import Recipe, ProjectLayer, Layer_Version, Machine, Project | 23 | from orm.models import Recipe, ProjectLayer, Layer_Version, Machine, Project |
24 | from orm.models import CustomImageRecipe, Package, Build, LogMessage, Task | 24 | from orm.models import CustomImageRecipe, Package, Build, LogMessage, Task |
25 | from orm.models import ProjectTarget | 25 | from orm.models import ProjectTarget |
26 | from django.db.models import Q, Max, Count | 26 | from django.db.models import Q, Max, Count, When, Case, Value, IntegerField |
27 | from django.conf.urls import url | 27 | from django.conf.urls import url |
28 | from django.core.urlresolvers import reverse, resolve | 28 | from django.core.urlresolvers import reverse, resolve |
29 | from django.http import HttpResponse | 29 | from django.http import HttpResponse |
@@ -927,6 +927,13 @@ class BuildsTable(ToasterTable): | |||
927 | return context | 927 | return context |
928 | 928 | ||
929 | def setup_queryset(self, *args, **kwargs): | 929 | def setup_queryset(self, *args, **kwargs): |
930 | """ | ||
931 | The queryset is annotated so that it can be sorted by number of | ||
932 | errors and number of warnings; but note that the criteria for | ||
933 | finding the log messages to populate these fields should match those | ||
934 | used in the Build model (orm/models.py) to populate the errors and | ||
935 | warnings properties | ||
936 | """ | ||
930 | queryset = self.get_builds() | 937 | queryset = self.get_builds() |
931 | 938 | ||
932 | # don't include in progress builds | 939 | # don't include in progress builds |
@@ -935,20 +942,27 @@ class BuildsTable(ToasterTable): | |||
935 | # sort | 942 | # sort |
936 | queryset = queryset.order_by(self.default_orderby) | 943 | queryset = queryset.order_by(self.default_orderby) |
937 | 944 | ||
938 | # annotate with number of ERROR and EXCEPTION log messages | 945 | # annotate with number of ERROR, EXCEPTION and CRITICAL log messages |
946 | criteria = (Q(logmessage__level=LogMessage.ERROR) | | ||
947 | Q(logmessage__level=LogMessage.EXCEPTION) | | ||
948 | Q(logmessage__level=LogMessage.CRITICAL)) | ||
949 | |||
939 | queryset = queryset.annotate( | 950 | queryset = queryset.annotate( |
940 | errors_no = Count( | 951 | errors_no=Count( |
941 | 'logmessage', | 952 | Case( |
942 | only = Q(logmessage__level=LogMessage.ERROR) | | 953 | When(criteria, then=Value(1)), |
943 | Q(logmessage__level=LogMessage.EXCEPTION) | 954 | output_field=IntegerField() |
955 | ) | ||
944 | ) | 956 | ) |
945 | ) | 957 | ) |
946 | 958 | ||
947 | # annotate with number of WARNING log messages | 959 | # annotate with number of WARNING log messages |
948 | queryset = queryset.annotate( | 960 | queryset = queryset.annotate( |
949 | warnings_no = Count( | 961 | warnings_no=Count( |
950 | 'logmessage', | 962 | Case( |
951 | only = Q(logmessage__level=LogMessage.WARNING) | 963 | When(logmessage__level=LogMessage.WARNING, then=Value(1)), |
964 | output_field=IntegerField() | ||
965 | ) | ||
952 | ) | 966 | ) |
953 | ) | 967 | ) |
954 | 968 | ||
@@ -1020,17 +1034,17 @@ class BuildsTable(ToasterTable): | |||
1020 | ''' | 1034 | ''' |
1021 | 1035 | ||
1022 | errors_template = ''' | 1036 | errors_template = ''' |
1023 | {% if data.errors.count %} | 1037 | {% if data.errors_no %} |
1024 | <a class="errors.count error" href="{% url "builddashboard" data.id %}#errors"> | 1038 | <a class="errors.count error" href="{% url "builddashboard" data.id %}#errors"> |
1025 | {{data.errors.count}} error{{data.errors.count|pluralize}} | 1039 | {{data.errors_no}} error{{data.errors_no|pluralize}} |
1026 | </a> | 1040 | </a> |
1027 | {% endif %} | 1041 | {% endif %} |
1028 | ''' | 1042 | ''' |
1029 | 1043 | ||
1030 | warnings_template = ''' | 1044 | warnings_template = ''' |
1031 | {% if data.warnings.count %} | 1045 | {% if data.warnings_no %} |
1032 | <a class="warnings.count warning" href="{% url "builddashboard" data.id %}#warnings"> | 1046 | <a class="warnings.count warning" href="{% url "builddashboard" data.id %}#warnings"> |
1033 | {{data.warnings.count}} warning{{data.warnings.count|pluralize}} | 1047 | {{data.warnings_no}} warning{{data.warnings_no|pluralize}} |
1034 | </a> | 1048 | </a> |
1035 | {% endif %} | 1049 | {% endif %} |
1036 | ''' | 1050 | ''' |