Filter the inactive builds when computing the is_building flag.

This commit is contained in:
yackob03 2013-10-27 16:00:44 -04:00
parent b1a5b9c343
commit 0ff19d5401
2 changed files with 11 additions and 5 deletions

View file

@ -562,10 +562,15 @@ def get_repository_build(request_dbid):
raise InvalidRepositoryBuildException(msg)
def list_repository_builds(namespace_name, repository_name):
def list_repository_builds(namespace_name, repository_name,
include_inactive=True):
joined = RepositoryBuild.select().join(Repository)
fetched = list(joined.where(Repository.name == repository_name,
Repository.namespace == namespace_name))
filtered = joined
if not include_inactive:
filtered = filtered.where(RepositoryBuild.phase != 'error',
RepositoryBuild.phase != 'complete')
fetched = list(filtered.where(Repository.name == repository_name,
Repository.namespace == namespace_name))
return fetched

View file

@ -345,7 +345,8 @@ def get_repo_api(namespace, repository):
tag_dict = {tag.name: tag_view(tag) for tag in tags}
can_write = ModifyRepositoryPermission(namespace, repository).can()
can_admin = AdministerRepositoryPermission(namespace, repository).can()
builds = model.list_repository_builds(namespace, repository)
active_builds = model.list_repository_builds(namespace, repository,
include_inactive=False)
return jsonify({
'namespace': namespace,
@ -355,7 +356,7 @@ def get_repo_api(namespace, repository):
'can_write': can_write,
'can_admin': can_admin,
'is_public': is_public,
'is_building': len(builds) > 0,
'is_building': len(active_builds) > 0,
})
abort(404) # Not fount