Skip to content

Commit

Permalink
toaster: orm Fix get_number_of_builds to count all apart from IN_PROG…
Browse files Browse the repository at this point in the history
…RESS

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>
  • Loading branch information
Michael Wood authored and rpurdie committed Nov 16, 2015
1 parent 4f70031 commit a981700
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions lib/toaster/orm/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,12 @@ def get_current_machine_name(self):
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:
Expand Down

0 comments on commit a981700

Please sign in to comment.