]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
toaster: orm Fix get_number_of_builds to count all apart from IN_PROGRESS
authorMichael Wood <michael.g.wood@intel.com>
Fri, 13 Nov 2015 13:48:34 +0000 (13:48 +0000)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Mon, 16 Nov 2015 11:43:38 +0000 (11:43 +0000)
The count of a project's builds should not include those which are
currently in progress.

Signed-off-by: Michael Wood <michael.g.wood@intel.com>
Signed-off-by: Elliot Smith <elliot.smith@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
lib/toaster/orm/models.py

index 3832905838f8d035940630c40231454c418e4c8f..0ac94b9339dd5e9ae2d343c24bcf7429cf59e048 100644 (file)
@@ -130,13 +130,12 @@ class Project(models.Model):
         try:
             return self.projectvariable_set.get(name="MACHINE").value
         except (ProjectVariable.DoesNotExist,IndexError):
-            return( "None" );
+            return None;
 
     def get_number_of_builds(self):
-        try:
-            return len(Build.objects.filter( project = self.id ))
-        except (Build.DoesNotExist,IndexError):
-            return( 0 )
+        """Return the number of builds which have ended"""
+
+        return self.build_set.filter(~Q(outcome=Build.IN_PROGRESS)).count()
 
     def get_last_build_id(self):
         try: