bitbake: toaster: orm Add sum of dependencies size function to PackageDependencyManager

Add function that returns the Sum of the size of all the packages which depend on a package.
Access get_total_source_deps_size via a packages's dependency
manager.

(Bitbake rev: e4c86d2f6c2e86ad054b37d0a5bf7464a4de4f9a)

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-11-04 14:48:54 +00:00 committed by Richard Purdie
parent a92fc3025b
commit 648753b30d
1 changed files with 7 additions and 1 deletions

View File

@ -20,7 +20,7 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
from django.db import models, IntegrityError
from django.db.models import F, Q, Avg, Max
from django.db.models import F, Q, Avg, Max, Sum
from django.utils import timezone
from django.core.urlresolvers import reverse
@ -727,6 +727,12 @@ class Package_DependencyManager(models.Manager):
def get_queryset(self):
return super(Package_DependencyManager, self).get_queryset().exclude(package_id = F('depends_on__id'))
def get_total_source_deps_size(self):
""" Returns the total file size of all the packages that depend on
thispackage.
"""
return self.all().aggregate(Sum('depends_on__size'))
class Package_Dependency(models.Model):
TYPE_RDEPENDS = 0
TYPE_TRDEPENDS = 1