diff --git a/data/model.py b/data/model.py index f796c3572..8c56da380 100644 --- a/data/model.py +++ b/data/model.py @@ -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 diff --git a/endpoints/api.py b/endpoints/api.py index 94e0daced..0d34b6a25 100644 --- a/endpoints/api.py +++ b/endpoints/api.py @@ -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