toaster: views Fix most frequently built target in project reporting
PATCH 1/1 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/lib/toaster/toastergui/views.py | 42 +++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 10 deletions(-)
bitbake/lib/toaster/toastergui/views.py +32 -10
@@ -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,)),
Signature · 1 line
2.7.4
Quoted 4 lines · On 01/07/2016 19:18, "[email protected] on behalf of Michael…
Clean up and fix the most frequently built targets for the "Most built recipes" section for the project configuration page.
[YOCTO #9846]
This works for me. Thanks!
Belén
Quoted 88 lines
Signed-off-by Michael Wood <[email protected]>---
bitbake/lib/toaster/toastergui/views.py| 42
+++++++++++++++++++++++++--------1 file changed, 32 insertions(+), 10 deletions(-)bitbake/lib/toaster/toastergui/views.py +0
-4@@ -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]bitbake/lib/toaster/toastergui/views.py +0
-4- except TypeError: - pass - freqtargets = Counter(freqtargets) - freqtargets = sorted(freqtargets, key = lambda x:freqtargets[x], reverse=True)
bitbake/lib/toaster/toastergui/views.py +9
-0+ + 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 aretwo
bitbake/lib/toaster/toastergui/views.py +22
-0+ # 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(),bitbake/lib/toaster/toastergui/views.py +1
-1@@ -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,)),
Signature · 7 lines
2.7.4 -- _______________________________________________ toaster mailing list [email protected] https://lists.yoctoproject.org/listinfo/toaster
Quoted 9 lines · Belen
Quoted 2 lines · On 01/07/2016 19:18, "[email protected] on behalf of Michael…
Clean up and fix the most frequently built targets for the "Most built recipes" section for the project configuration page.
Upstreamed to bitbake-devel and pushed to toaster-next.
Thanks.
Elliot
Quoted 102 lines
Quoted 2 lines
[YOCTO #9846]
This works for me. Thanks!
Belén
Quoted 83 lines
Signed-off-by Michael Wood <[email protected]>---
bitbake/lib/toaster/toastergui/views.py| 42
+++++++++++++++++++++++++--------1 file changed, 32 insertions(+), 10 deletions(-)bitbake/lib/toaster/toastergui/views.py +0
-4@@ -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]bitbake/lib/toaster/toastergui/views.py +0
-4- except TypeError: - pass - freqtargets = Counter(freqtargets) - freqtargets = sorted(freqtargets, key = lambda x:freqtargets[x], reverse=True)
bitbake/lib/toaster/toastergui/views.py +9
-0+ + 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 aretwo
bitbake/lib/toaster/toastergui/views.py +22
-0+ # 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(),bitbake/lib/toaster/toastergui/views.py +1
-1@@ -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,)),
--
2.7.4Quoted 5 lines
--
_______________________________________________
toaster mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/toaster--
_______________________________________________
toaster mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/toaster
Signature · 3 lines
Elliot Smith Software Engineer Intel Open Source Technology Centre