From fdccba9d8e619763236f9debd4443f28fee6d852 Mon Sep 17 00:00:00 2001 From: jakedt Date: Wed, 5 Mar 2014 16:17:01 -0500 Subject: [PATCH] Reverse the order of the builds from the API. --- data/model.py | 18 ++++++------------ static/partials/repo-build.html | 2 +- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/data/model.py b/data/model.py index 33ceebaff..c39f9627e 100644 --- a/data/model.py +++ b/data/model.py @@ -1413,6 +1413,7 @@ def list_repository_builds(namespace_name, repository_name, limit, .join(BuildTriggerService, JOIN_LEFT_OUTER) .where(Repository.name == repository_name, Repository.namespace == namespace_name) + .order_by(RepositoryBuild.started.desc()) .limit(limit)) if not include_inactive: @@ -1423,18 +1424,11 @@ def list_repository_builds(namespace_name, repository_name, limit, def get_recent_repository_build(namespace_name, repository_name): - query = (RepositoryBuild.select(RepositoryBuild) - .join(Repository) - .where(Repository.name == repository_name, - Repository.namespace == namespace_name) - .order_by(RepositoryBuild.started.desc()) - .limit(1)) - - results = list(query) - if results: - return results[0] - - return None + query = list_repository_builds(namespace_name, repository_name, 1) + try: + return query.get() + except RepositoryBuild.DoesNotExist: + return None def create_repository_build(repo, access_token, job_config_obj, dockerfile_id, diff --git a/static/partials/repo-build.html b/static/partials/repo-build.html index 252396007..a4e4b253f 100644 --- a/static/partials/repo-build.html +++ b/static/partials/repo-build.html @@ -26,7 +26,7 @@