1
0
mirror of https://git.yoctoproject.org/poky synced 2026-05-30 12:29:55 +00:00

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 <michael.g.wood@intel.com>
Signed-off-by: brian avery <avery.brian@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Michael Wood
2015-12-08 11:29:23 +00:00
committed by Richard Purdie
parent 20f400b7bd
commit 9ea4de6d80
+16 -11
View File
@@ -22,8 +22,8 @@
from toastergui.widgets import ToasterTable from toastergui.widgets import ToasterTable
from orm.models import Recipe, ProjectLayer, Layer_Version, Machine, Project from orm.models import Recipe, ProjectLayer, Layer_Version, Machine, Project
from orm.models import CustomImageRecipe, Package, Target, Build, LogMessage, Task from orm.models import CustomImageRecipe, Package, Target, Build, LogMessage, Task
from orm.models import ProjectTarget from orm.models import CustomImagePackage, ProjectTarget
from django.db.models import Q, Max, Count, When, Case, Value, IntegerField from django.db.models import Q, Max, Sum, Count, When, Case, Value, IntegerField
from django.conf.urls import url from django.conf.urls import url
from django.core.urlresolvers import reverse, resolve from django.core.urlresolvers import reverse, resolve
from django.http import HttpResponse from django.http import HttpResponse
@@ -731,15 +731,19 @@ class SelectPackagesTable(PackagesTable):
cust_recipe = CustomImageRecipe.objects.get(pk=kwargs['recipeid']) cust_recipe = CustomImageRecipe.objects.get(pk=kwargs['recipeid'])
prj = Project.objects.get(pk = kwargs['pid']) 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 current_recipes = prj.get_available_recipes()
# Get all the packages built by builds in the current project
# but not those ones that are already in the custom image # Exclude ghost packages and ones which have locale in the name
self.queryset = Package.objects.filter( # This is a work around locale packages being dynamically created
Q(pk__in=current_packages) | # and therefore not recognised as packages by bitbake.
(Q(build__project=prj) & # We also only show packages which recipes->layers are in the project
~Q(name__in=current_packages.values_list('name')))) 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') self.queryset = self.queryset.order_by('name')
@@ -752,7 +756,8 @@ class SelectPackagesTable(PackagesTable):
custom_recipe = CustomImageRecipe.objects.get(pk=kwargs['recipe_id']) custom_recipe = CustomImageRecipe.objects.get(pk=kwargs['recipe_id'])
context['recipe'] = custom_recipe 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 return context