aboutsummaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
authorMichael Wood <michael.g.wood@intel.com>2016-07-04 16:34:46 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-07-08 09:57:28 +0100
commitdab3b1b45486b2da0df23bd9e9715046a8a0515c (patch)
tree80ad5db37ded85518271edc5c2d05bc0c377329e /bitbake
parent5018d5f095ab4ab2ddd2ba164566d39d4578ce05 (diff)
downloadopenembedded-core-contrib-dab3b1b45486b2da0df23bd9e9715046a8a0515c.tar.gz
bitbake: toaster: views Fix most frequently built target in project reporting
Clean up and fix the most frequently built targets for the "Most built recipes" section for the project configuration page. [YOCTO #9846] (Bitbake rev: 860475cfdd35301fb609ab3c89347566b0ca0adc) Signed-off-by: Michael Wood <michael.g.wood@intel.com> Signed-off-by: Elliot Smith <elliot.smith@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rwxr-xr-xbitbake/lib/toaster/toastergui/views.py42
1 files changed, 32 insertions, 10 deletions
diff --git a/bitbake/lib/toaster/toastergui/views.py b/bitbake/lib/toaster/toastergui/views.py
index c40273c8ba..2db68bdd4d 100755
--- a/bitbake/lib/toaster/toastergui/views.py
+++ b/bitbake/lib/toaster/toastergui/views.py
@@ -1404,15 +1404,37 @@ if True:
pid = prj.id
from collections import Counter
- freqtargets = []
- try:
- btargets = sum(build.target_set.all() for build in Build.objects.filter(project=prj, outcome__lt=Build.IN_PROGRESS))
- brtargets = sum(br.brtarget_set.all() for br in BuildRequest.objects.filter(project = prj, state = BuildRequest.REQ_FAILED))
- freqtargets = [x.target for x in btargets] + [x.target for x in brtargets]
- except TypeError:
- pass
- freqtargets = Counter(freqtargets)
- freqtargets = sorted(freqtargets, key = lambda x: freqtargets[x], reverse=True)
+
+ freqtargets = Counter(Target.objects.filter(
+ Q(build__project=prj),
+ ~Q(build__outcome=Build.IN_PROGRESS)
+ ).order_by("target").values_list("target", flat=True))
+
+ freqtargets = freqtargets.most_common(5)
+
+ # We now have the targets in order of frequency but if there are two
+ # with the same frequency then we need to make sure those are in
+ # alphabetical order without losing the frequency ordering
+
+ tmp = []
+ switch = None
+ for i, freqtartget in enumerate(freqtargets):
+ target, count = freqtartget
+ try:
+ target_next, count_next = freqtargets[i+1]
+ if count == count_next and target > target_next:
+ switch = target
+ continue
+ except IndexError:
+ pass
+
+ tmp.append(target)
+
+ if switch:
+ tmp.append(switch)
+ switch = None
+
+ freqtargets = tmp
layers = [{"id": x.layercommit.pk, "orderid": x.pk, "name" : x.layercommit.layer.name,
"vcs_url": x.layercommit.layer.vcs_url, "vcs_reference" : x.layercommit.get_vcs_reference(),
@@ -1432,7 +1454,7 @@ if True:
"layers" : layers,
"targets" : [{"target" : x.target, "task" : x.task, "pk": x.pk} for x in prj.projecttarget_set.all()],
"variables": [(x.name, x.value) for x in prj.projectvariable_set.all()],
- "freqtargets": freqtargets[:5],
+ "freqtargets": freqtargets,
"releases": [{"id": x.pk, "name": x.name, "description":x.description} for x in Release.objects.all()],
"project_html": 1,
"recipesTypeAheadUrl": reverse('xhr_recipestypeahead', args=(prj.pk,)),