diff options
author | Michael Wood <michael.g.wood@intel.com> | 2016-07-04 16:34:46 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-07-08 09:57:28 +0100 |
commit | dab3b1b45486b2da0df23bd9e9715046a8a0515c (patch) | |
tree | 80ad5db37ded85518271edc5c2d05bc0c377329e | |
parent | 5018d5f095ab4ab2ddd2ba164566d39d4578ce05 (diff) | |
download | poky-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>
-rwxr-xr-x | bitbake/lib/toaster/toastergui/views.py | 42 |
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: | |||
1404 | pid = prj.id | 1404 | pid = prj.id |
1405 | 1405 | ||
1406 | from collections import Counter | 1406 | from collections import Counter |
1407 | freqtargets = [] | 1407 | |
1408 | try: | 1408 | freqtargets = Counter(Target.objects.filter( |
1409 | btargets = sum(build.target_set.all() for build in Build.objects.filter(project=prj, outcome__lt=Build.IN_PROGRESS)) | 1409 | Q(build__project=prj), |
1410 | brtargets = sum(br.brtarget_set.all() for br in BuildRequest.objects.filter(project = prj, state = BuildRequest.REQ_FAILED)) | 1410 | ~Q(build__outcome=Build.IN_PROGRESS) |
1411 | freqtargets = [x.target for x in btargets] + [x.target for x in brtargets] | 1411 | ).order_by("target").values_list("target", flat=True)) |
1412 | except TypeError: | 1412 | |
1413 | pass | 1413 | freqtargets = freqtargets.most_common(5) |
1414 | freqtargets = Counter(freqtargets) | 1414 | |
1415 | freqtargets = sorted(freqtargets, key = lambda x: freqtargets[x], reverse=True) | 1415 | # We now have the targets in order of frequency but if there are two |
1416 | # with the same frequency then we need to make sure those are in | ||
1417 | # alphabetical order without losing the frequency ordering | ||
1418 | |||
1419 | tmp = [] | ||
1420 | switch = None | ||
1421 | for i, freqtartget in enumerate(freqtargets): | ||
1422 | target, count = freqtartget | ||
1423 | try: | ||
1424 | target_next, count_next = freqtargets[i+1] | ||
1425 | if count == count_next and target > target_next: | ||
1426 | switch = target | ||
1427 | continue | ||
1428 | except IndexError: | ||
1429 | pass | ||
1430 | |||
1431 | tmp.append(target) | ||
1432 | |||
1433 | if switch: | ||
1434 | tmp.append(switch) | ||
1435 | switch = None | ||
1436 | |||
1437 | freqtargets = tmp | ||
1416 | 1438 | ||
1417 | layers = [{"id": x.layercommit.pk, "orderid": x.pk, "name" : x.layercommit.layer.name, | 1439 | layers = [{"id": x.layercommit.pk, "orderid": x.pk, "name" : x.layercommit.layer.name, |
1418 | "vcs_url": x.layercommit.layer.vcs_url, "vcs_reference" : x.layercommit.get_vcs_reference(), | 1440 | "vcs_url": x.layercommit.layer.vcs_url, "vcs_reference" : x.layercommit.get_vcs_reference(), |
@@ -1432,7 +1454,7 @@ if True: | |||
1432 | "layers" : layers, | 1454 | "layers" : layers, |
1433 | "targets" : [{"target" : x.target, "task" : x.task, "pk": x.pk} for x in prj.projecttarget_set.all()], | 1455 | "targets" : [{"target" : x.target, "task" : x.task, "pk": x.pk} for x in prj.projecttarget_set.all()], |
1434 | "variables": [(x.name, x.value) for x in prj.projectvariable_set.all()], | 1456 | "variables": [(x.name, x.value) for x in prj.projectvariable_set.all()], |
1435 | "freqtargets": freqtargets[:5], | 1457 | "freqtargets": freqtargets, |
1436 | "releases": [{"id": x.pk, "name": x.name, "description":x.description} for x in Release.objects.all()], | 1458 | "releases": [{"id": x.pk, "name": x.name, "description":x.description} for x in Release.objects.all()], |
1437 | "project_html": 1, | 1459 | "project_html": 1, |
1438 | "recipesTypeAheadUrl": reverse('xhr_recipestypeahead', args=(prj.pk,)), | 1460 | "recipesTypeAheadUrl": reverse('xhr_recipestypeahead', args=(prj.pk,)), |