From 9ea4de6d801d57a35e46cb6e433b3fbcc71d378f Mon Sep 17 00:00:00 2001 From: Michael Wood Date: Tue, 8 Dec 2015 11:29:23 +0000 Subject: bitbake: toaster: tables Change SelectPackagesTable to use ProjectPackage 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. (Bitbake rev: 4b4b7e28d602ac5283659f806d695cc0451d292e) Signed-off-by: Michael Wood Signed-off-by: brian avery Signed-off-by: Richard Purdie --- bitbake/lib/toaster/toastergui/tables.py | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) (limited to 'bitbake/lib/toaster/toastergui') diff --git a/bitbake/lib/toaster/toastergui/tables.py b/bitbake/lib/toaster/toastergui/tables.py index ecca22037a..48829351b4 100644 --- a/bitbake/lib/toaster/toastergui/tables.py +++ b/bitbake/lib/toaster/toastergui/tables.py @@ -22,8 +22,8 @@ from toastergui.widgets import ToasterTable from orm.models import Recipe, ProjectLayer, Layer_Version, Machine, Project from orm.models import CustomImageRecipe, Package, Target, Build, LogMessage, Task -from orm.models import ProjectTarget -from django.db.models import Q, Max, Count, When, Case, Value, IntegerField +from orm.models import CustomImagePackage, ProjectTarget +from django.db.models import Q, Max, Sum, Count, When, Case, Value, IntegerField from django.conf.urls import url from django.core.urlresolvers import reverse, resolve from django.http import HttpResponse @@ -731,15 +731,19 @@ 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 = CustomImagePackage.objects.filter( + ~Q(recipe=None) & + Q(recipe__in=current_recipes) & + ~Q(name__icontains="locale") & + ~Q(name__icontains="packagegroup")) self.queryset = self.queryset.order_by('name') @@ -752,7 +756,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 -- cgit v1.2.3-54-g00ecf