From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by yocto-www.yoctoproject.org (Postfix, from userid 118) id E8663E00EC1; Wed, 7 Oct 2015 09:17:15 -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=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 X-Spam-HAM-Report: * -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% * [score: 0.0000] * -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low * trust * [209.85.212.180 listed in list.dnswl.org] Received: from mail-wi0-f180.google.com (mail-wi0-f180.google.com [209.85.212.180]) by yocto-www.yoctoproject.org (Postfix) with ESMTP id 7C68CE00843 for ; Wed, 7 Oct 2015 09:17:11 -0700 (PDT) Received: by wicfx3 with SMTP id fx3so220412524wic.1 for ; Wed, 07 Oct 2015 09:17:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :cc:subject:references:in-reply-to:content-type :content-transfer-encoding; bh=ojhixjHEweATBHgF3PTxBvPWSHHPX+70UV++vthJ0F0=; b=CdQQDEMwKGRAl5D+LK1OeeLEmPuWxowhkmGRZEq8Qu+nsBqGtO8Fs5gZDJDmqZ/dbH bcIa7DVzY7S1qkOd7nw7+3HYwICfH4RENdggJvWDWJs+gOSNvW3vPG6mJGColhzB6WOo cDcUMCVUhN0GXq/zFQRwsklWCfSnrRuBOjOBHu1+6qvyAkVJfiVQ042KVLEAN7UfywQk VC3XlYPFvxVTXSQlFtxb5niCG5jY62Soro4aXZY+tzWaL9EhHG3NxuSkhZqXIhEozCns L8lqezxnZmxWuRCYOgLMtyVZrfRm0aHpOPf6CGD/fKgX1ZTm2G+vQ7P/2vbeUejeM4Cl jA3w== X-Gm-Message-State: ALoCoQlwwmUPh8djmTX8TC9KpvP/mFSJ/MU1po1vgSWEVGUrgGCcoHXkEm0a5A7gugJgJcpblPD/ X-Received: by 10.180.188.206 with SMTP id gc14mr8170999wic.37.1444234630869; Wed, 07 Oct 2015 09:17:10 -0700 (PDT) Received: from [192.168.0.22] ([2.218.205.118]) by smtp.googlemail.com with ESMTPSA id bh5sm40195299wjb.42.2015.10.07.09.17.09 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 07 Oct 2015 09:17:10 -0700 (PDT) Message-ID: <56154585.3060101@intel.com> Date: Wed, 07 Oct 2015 17:17:09 +0100 From: Michael Wood User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.8.0 MIME-Version: 1.0 To: Ed Bartosh , "toaster@yoctoproject.org" References: <3bc71fb705081ed2a00819f76720f985ca5cc223.1443707344.git.ed.bartosh@linux.intel.com> In-Reply-To: <3bc71fb705081ed2a00819f76720f985ca5cc223.1443707344.git.ed.bartosh@linux.intel.com> Subject: Re: [PATCH 1/5] toaster: implement API to get full list of deps 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: Wed, 07 Oct 2015 16:17:16 -0000 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit On 01/10/15 14:56, Ed Bartosh wrote: > Implemented Layer_Version.get_alldeps API to recursively get > full list of dependencies for the layer. Dependencies that are > already in the project are filtered out from the result. > Result list of Layer_Version objects is sorted by layer name > for UI to look consistent. > > This API is going to be used to show amount and list of > dependencies for the layer in the list of compatible layers > for the project. > > Signed-off-by: Ed Bartosh > --- > bitbake/lib/toaster/orm/models.py | 19 +++++++++++++++++++ > 1 file changed, 19 insertions(+) > > diff --git a/bitbake/lib/toaster/orm/models.py b/bitbake/lib/toaster/orm/models.py > index 5aed158..c5e256f 100644 > --- a/bitbake/lib/toaster/orm/models.py > +++ b/bitbake/lib/toaster/orm/models.py > @@ -1177,6 +1177,25 @@ class Layer_Version(models.Model): > def get_detailspage_url(self, project_id): > return reverse('layerdetails', args=(project_id, self.pk)) > > + def get_alldeps(self, project_id): > + """Get full list of unique layer dependencies.""" > + def gen_layerdeps(lver, project): > + for ldep in lver.dependencies.all(): > + yield ldep.depends_on > + # get next level of deps recursively calling gen_layerdeps > + for subdep in gen_layerdeps(ldep.depends_on, project): > + yield subdep > + > + project = Project.objects.get(pk=project_id) > + result = [] > + projectlvers = [player.layercommit for player in project.projectlayer_set.all()] > + for dep in gen_layerdeps(self, project): > + # filter out duplicates and layers already belonging to the project > + if dep not in result + projectlvers: > + result.append(dep) > + > + return sorted(result, key=lambda x: x.layer.name) > + > def __unicode__(self): > return "%d %s (VCS %s, Project %s)" % (self.pk, str(self.layer), self.get_vcs_reference(), self.build.project if self.build is not None else "No project") > Sorry for too late review, spotted a regression. This will cause a regression in the layerdetails page, the API should not be filtering out any layer dependencies that are already added to the project. - This is already done in the client side logic which is why the context has projectlayers in it - The layerdetails page is supposed to list the dependencies for the layer regardless as to whether they have been added or not. (btw you can do something like this self.dependencies.exclude(depends_on__in=prj.get_project_layer_versions()) if you want a list of the layers it depends on but are not added, rather than iterate through these and create a new list) As it's been submitted would you be able to write a patch on top to fix this. Michael