Return-Path: Received: by yocto-www.yoctoproject.org (Postfix, from userid 118) id AE5E9E00BC2; Tue, 8 Dec 2015 13:18:03 -0800 (PST) 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,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 X-Spam-HAM-Report: * -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low * trust * [209.85.192.174 listed in list.dnswl.org] * -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% * [score: 0.0000] * 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily * valid * -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Received: from mail-pf0-f174.google.com (mail-pf0-f174.google.com [209.85.192.174]) by yocto-www.yoctoproject.org (Postfix) with ESMTP id 351C6E00BC2 for ; Tue, 8 Dec 2015 13:17:47 -0800 (PST) Received: by pfu207 with SMTP id 207so17959751pfu.2 for ; Tue, 08 Dec 2015 13:17:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Wnw773xAUZQDOGMAJ+v3KWufCbMyLkbBGaW0+mfHVj8=; b=IkUB7g4M5mZ6M6lkJBWXlDQPJR/Q0tQDe1uG9/pQDOAAnlLoacPiJ4xDf4Aw/U4tDi JZ/wi4aJmoJ4LrC9btx0hYWASBf/nLkrNRMfnEub5tnuxFlfvSy1gglR3N8OzB6JmvFh ew2fVFdyUb25jXvgmSirJ2yh/4Hm2wTg5hfR80+C4gKm1Y6c+liQoC6P9nxsJSZ3qIX3 KnMzFZ2MlGCF8B2YEy6iqz9qNOH9Abx16i4NDHm5G08+a4aq3/lSbSs1zz8ShRMT4zQi TnCrdiYIZuIhz9l/xImQeTbpBD2tlFe4fWRBRg6Z2TF5KZWk0lpGY9MG+ZH1xb3nCLu6 MARA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Wnw773xAUZQDOGMAJ+v3KWufCbMyLkbBGaW0+mfHVj8=; b=kPpNTSh7o4A6XEjUs0nYglqHpfFpjYgfhQcw8jr6GdBsq2Jo575qk005Wm7sZaFkCn EhyVyY+BKuOlHwmU7DE7nTAJgXUtrvVmfejRkHTfqoCkaAhp4LhhqaHvz4otjJuvZEwx FLV817g+n748HRF62LYhX/y8a5w38cEw2RqCz9XntiIS5TabLdR+Ct7eQBMKwFgOR6EA NJKilXYLn2lYVkW6Y1zTNnyWVjBdjLUY6uRQYmNol/i8gBdV0SB3cw9V9f8ZjQgwyFeS nLFWcIQ9l/0RFP3yYsnoRhU3j0zmHCIfWCZGOmhM2JbWO0lavK5m/TEbbvoEQx1vGYhg 78Gg== X-Gm-Message-State: ALoCoQnLwewvvkDiDJ3J4u4+oS9qyM2V4fliLY8R0vjZ7pe+4yghAdIlOeEVwyeF2lBxR5Ss0qOjb/Ts5Y/gXzXRQH7a/i9+2A== X-Received: by 10.98.15.68 with SMTP id x65mr8098247pfi.146.1449609467505; Tue, 08 Dec 2015 13:17:47 -0800 (PST) Received: from draco.ger.corp.intel.com ([192.55.54.40]) by smtp.gmail.com with ESMTPSA id v64sm6675766pfi.50.2015.12.08.13.17.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 08 Dec 2015 13:17:46 -0800 (PST) From: Michael Wood To: toaster@yoctoproject.org Date: Tue, 8 Dec 2015 21:16:13 +0000 Message-Id: <1449609380-11073-28-git-send-email-michael.g.wood@intel.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1449609380-11073-1-git-send-email-michael.g.wood@intel.com> References: <1449609380-11073-1-git-send-email-michael.g.wood@intel.com> Subject: [PATCH 27/34] toaster: tables Change SelectPackagesTable to use ProjectPackage 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: Tue, 08 Dec 2015 21:18:03 -0000 This changes the SelectPackagesTable to use the ProjectPackage table instead of very large expensive queries to retrieve a list of currently available packages for the project. Signed-off-by: Michael Wood --- bitbake/lib/toaster/toastergui/tables.py | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/bitbake/lib/toaster/toastergui/tables.py b/bitbake/lib/toaster/toastergui/tables.py index 8147c1b..9476887 100644 --- a/bitbake/lib/toaster/toastergui/tables.py +++ b/bitbake/lib/toaster/toastergui/tables.py @@ -22,6 +22,7 @@ from toastergui.widgets import ToasterTable from orm.models import Recipe, ProjectLayer, Layer_Version, Machine, Project from orm.models import CustomImageRecipe, Package, Target, Build +from orm.models import ProjectPackage from django.db.models import Q, Max, Sum from django.conf.urls import url from django.core.urlresolvers import reverse @@ -677,7 +678,7 @@ class PackagesTable(ToasterTable): class SelectPackagesTable(PackagesTable): - """ Table to display the packages to add and remove from an image """ + """ Table to display packages to add and remove from a custom recipe""" def __init__(self, *args, **kwargs): super(SelectPackagesTable, self).__init__(*args, **kwargs) @@ -687,15 +688,20 @@ class SelectPackagesTable(PackagesTable): cust_recipe = CustomImageRecipe.objects.get(pk=kwargs['recipeid']) prj = Project.objects.get(pk = kwargs['pid']) - current_packages = cust_recipe.packages.all() + current_packages = self.cust_recipe.get_all_packages() - # Get all the packages that are in the custom image - # Get all the packages built by builds in the current project - # but not those ones that are already in the custom image - self.queryset = Package.objects.filter( - Q(pk__in=current_packages) | - (Q(build__project=prj) & - ~Q(name__in=current_packages.values_list('name')))) + current_recipes = prj.get_available_recipes() + + # Exclude ghost packages and ones which have locale in the name + # This is a work around locale packages being dynamically created + # and therefore not recognised as packages by bitbake. + # We also only show packages which recipes->layers are in the project + self.queryset = ProjectPackage.objects.filter( + Q(project=prj) & + ~Q(recipe=None) & + Q(recipe__in=current_recipes) & + ~Q(name__icontains="locale") & + ~Q(name__icontains="packagegroup")) self.queryset = self.queryset.order_by('name') @@ -708,7 +714,8 @@ class SelectPackagesTable(PackagesTable): custom_recipe = CustomImageRecipe.objects.get(pk=kwargs['recipe_id']) context['recipe'] = custom_recipe - context['approx_pkg_size'] = custom_recipe.package_set.aggregate(Sum('size')) + context['approx_pkg_size'] = \ + custom_recipe.get_all_packages().aggregate(Sum('size')) return context -- 2.1.4