All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] toaster: views Fix most frequently built target in project reporting
@ 2016-07-01 18:18 Michael Wood
  2016-07-04 14:49 ` Barros Pena, Belen
  0 siblings, 1 reply; 3+ messages in thread
From: Michael Wood @ 2016-07-01 18:18 UTC (permalink / raw)
  To: toaster

Clean up and fix the most frequently built targets for the "Most built
recipes" section for the project configuration page.

[YOCTO #9846]

Signed-off-by: Michael Wood <michael.g.wood@intel.com>
---
 bitbake/lib/toaster/toastergui/views.py | 42 +++++++++++++++++++++++++--------
 1 file changed, 32 insertions(+), 10 deletions(-)

diff --git a/bitbake/lib/toaster/toastergui/views.py b/bitbake/lib/toaster/toastergui/views.py
index c40273c..2db68bd 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,)),
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] toaster: views Fix most frequently built target in project reporting
  2016-07-01 18:18 [PATCH] toaster: views Fix most frequently built target in project reporting Michael Wood
@ 2016-07-04 14:49 ` Barros Pena, Belen
  2016-07-04 15:36   ` Smith, Elliot
  0 siblings, 1 reply; 3+ messages in thread
From: Barros Pena, Belen @ 2016-07-04 14:49 UTC (permalink / raw)
  To: Wood, Michael G, toaster



On 01/07/2016 19:18, "toaster-bounces@yoctoproject.org on behalf of
Michael Wood" <toaster-bounces@yoctoproject.org on behalf of
michael.g.wood@intel.com> wrote:

>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

>
>Signed-off-by: Michael Wood <michael.g.wood@intel.com>
>---
> bitbake/lib/toaster/toastergui/views.py | 42
>+++++++++++++++++++++++++--------
> 1 file changed, 32 insertions(+), 10 deletions(-)
>
>diff --git a/bitbake/lib/toaster/toastergui/views.py
>b/bitbake/lib/toaster/toastergui/views.py
>index c40273c..2db68bd 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,)),
>-- 
>2.7.4
>
>-- 
>_______________________________________________
>toaster mailing list
>toaster@yoctoproject.org
>https://lists.yoctoproject.org/listinfo/toaster



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] toaster: views Fix most frequently built target in project reporting
  2016-07-04 14:49 ` Barros Pena, Belen
@ 2016-07-04 15:36   ` Smith, Elliot
  0 siblings, 0 replies; 3+ messages in thread
From: Smith, Elliot @ 2016-07-04 15:36 UTC (permalink / raw)
  To: Barros Pena, Belen; +Cc: toaster

[-- Attachment #1: Type: text/plain, Size: 4225 bytes --]

On 4 July 2016 at 15:49, Barros Pena, Belen <belen.barros.pena@intel.com>
wrote:

>
>
> On 01/07/2016 19:18, "toaster-bounces@yoctoproject.org on behalf of
> Michael Wood" <toaster-bounces@yoctoproject.org on behalf of
> michael.g.wood@intel.com> wrote:
>
> >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



> >
> >[YOCTO #9846]
>
> This works for me. Thanks!
>
> Belén
>
> >
> >Signed-off-by: Michael Wood <michael.g.wood@intel.com>
> >---
> > bitbake/lib/toaster/toastergui/views.py | 42
> >+++++++++++++++++++++++++--------
> > 1 file changed, 32 insertions(+), 10 deletions(-)
> >
> >diff --git a/bitbake/lib/toaster/toastergui/views.py
> >b/bitbake/lib/toaster/toastergui/views.py
> >index c40273c..2db68bd 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,)),
> >--
> >2.7.4
> >
> >--
> >_______________________________________________
> >toaster mailing list
> >toaster@yoctoproject.org
> >https://lists.yoctoproject.org/listinfo/toaster
>
> --
> _______________________________________________
> toaster mailing list
> toaster@yoctoproject.org
> https://lists.yoctoproject.org/listinfo/toaster
>



-- 
Elliot Smith
Software Engineer
Intel Open Source Technology Centre

[-- Attachment #2: Type: text/html, Size: 7117 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-07-04 15:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-01 18:18 [PATCH] toaster: views Fix most frequently built target in project reporting Michael Wood
2016-07-04 14:49 ` Barros Pena, Belen
2016-07-04 15:36   ` Smith, Elliot

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.