Return-Path: Received: by yocto-www.yoctoproject.org (Postfix, from userid 118) id 9D5EFE00CF0; Mon, 4 Jul 2016 07:49:47 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on yocto-www.yoctoproject.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 X-Spam-HAM-Report: * -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/, high * trust * [192.55.52.115 listed in list.dnswl.org] * -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% * [score: 0.0000] Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by yocto-www.yoctoproject.org (Postfix) with ESMTP id 52CEBE00C31 for ; Mon, 4 Jul 2016 07:49:44 -0700 (PDT) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga103.fm.intel.com with ESMTP; 04 Jul 2016 07:49:44 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,575,1459839600"; d="scan'208";a="1000675273" Received: from irsmsx107.ger.corp.intel.com ([163.33.3.99]) by fmsmga001.fm.intel.com with ESMTP; 04 Jul 2016 07:49:43 -0700 Received: from irsmsx110.ger.corp.intel.com ([169.254.15.97]) by IRSMSX107.ger.corp.intel.com ([169.254.10.96]) with mapi id 14.03.0248.002; Mon, 4 Jul 2016 15:49:42 +0100 From: "Barros Pena, Belen" To: "Wood, Michael G" , "toaster@yoctoproject.org" Thread-Topic: [Toaster] [PATCH] toaster: views Fix most frequently built target in project reporting Thread-Index: AQHR1gNLEVR77KECO02a9pAosuOtYQ== Date: Mon, 4 Jul 2016 14:49:41 +0000 Message-ID: References: <1467397130-31797-1-git-send-email-michael.g.wood@intel.com> In-Reply-To: <1467397130-31797-1-git-send-email-michael.g.wood@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: user-agent: Microsoft-MacOutlook/14.6.5.160527 x-originating-ip: [10.252.9.233] MIME-Version: 1.0 Subject: Re: [PATCH] toaster: views Fix most frequently built target in project reporting X-BeenThere: toaster@yoctoproject.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Web based interface for BitBake List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 Jul 2016 14:49:47 -0000 Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-ID: <02A68F0E8774344280FB26DDD1F0A312@intel.com> Content-Transfer-Encoding: quoted-printable On 01/07/2016 19:18, "toaster-bounces@yoctoproject.org on behalf of Michael Wood" 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=E9n > >Signed-off-by: Michael Wood >--- > 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 =3D prj.id >=20 > from collections import Counter >- freqtargets =3D [] >- try: >- btargets =3D sum(build.target_set.all() for build in >Build.objects.filter(project=3Dprj, outcome__lt=3DBuild.IN_PROGRESS)) >- brtargets =3D sum(br.brtarget_set.all() for br in >BuildRequest.objects.filter(project =3D prj, state =3D >BuildRequest.REQ_FAILED)) >- freqtargets =3D [x.target for x in btargets] + [x.target for = x >in brtargets] >- except TypeError: >- pass >- freqtargets =3D Counter(freqtargets) >- freqtargets =3D sorted(freqtargets, key =3D lambda x: >freqtargets[x], reverse=3DTrue) >+ >+ freqtargets =3D Counter(Target.objects.filter( >+ Q(build__project=3Dprj), >+ ~Q(build__outcome=3DBuild.IN_PROGRESS) >+ ).order_by("target").values_list("target", flat=3DTrue)) >+ >+ freqtargets =3D 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 =3D [] >+ switch =3D None >+ for i, freqtartget in enumerate(freqtargets): >+ target, count =3D freqtartget >+ try: >+ target_next, count_next =3D freqtargets[i+1] >+ if count =3D=3D count_next and target > target_next: >+ switch =3D target >+ continue >+ except IndexError: >+ pass >+ >+ tmp.append(target) >+ >+ if switch: >+ tmp.append(switch) >+ switch =3D None >+ >+ freqtargets =3D tmp >=20 > layers =3D [{"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=3D(prj.pk,)), >--=20 >2.7.4 > >--=20 >_______________________________________________ >toaster mailing list >toaster@yoctoproject.org >https://lists.yoctoproject.org/listinfo/toaster