Fix MySQL issue and enable sorting by description
This commit is contained in:
parent
a53a0a44a9
commit
8a492a9d56
2 changed files with 6 additions and 5 deletions
|
@ -514,7 +514,7 @@ def get_visible_repository_internal(username=None, include_public=True, limit=No
|
||||||
return []
|
return []
|
||||||
|
|
||||||
query = (Repository
|
query = (Repository
|
||||||
.select(Repository, Visibility)
|
.select() # Note: We need to leave this blank for the get_count case. Otherwise, MySQL/RDS complains.
|
||||||
.distinct()
|
.distinct()
|
||||||
.join(Visibility)
|
.join(Visibility)
|
||||||
.switch(Repository)
|
.switch(Repository)
|
||||||
|
@ -563,8 +563,7 @@ def get_visible_repository_internal(username=None, include_public=True, limit=No
|
||||||
where_clause = new_clause
|
where_clause = new_clause
|
||||||
|
|
||||||
if sort:
|
if sort:
|
||||||
# TODO: Add the sorting clause here.
|
query = query.order_by(Repository.description.desc())
|
||||||
pass
|
|
||||||
|
|
||||||
if page:
|
if page:
|
||||||
query = query.paginate(page, limit)
|
query = query.paginate(page, limit)
|
||||||
|
|
|
@ -99,11 +99,13 @@ function RepoListCtrl($scope, Restangular, UserService, ApiService) {
|
||||||
'sort': true,
|
'sort': true,
|
||||||
'limit': 10,
|
'limit': 10,
|
||||||
'page': $scope.page,
|
'page': $scope.page,
|
||||||
'count': true
|
'count': $scope.page == 1
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.public_repositories = ApiService.listReposAsResource().withOptions(options).get(function(resp) {
|
$scope.public_repositories = ApiService.listReposAsResource().withOptions(options).get(function(resp) {
|
||||||
$scope.publicPageCount = Math.ceil(resp.count / 10);
|
if (resp.count) {
|
||||||
|
$scope.publicPageCount = Math.ceil(resp.count / 10);
|
||||||
|
}
|
||||||
return resp.repositories;
|
return resp.repositories;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
Reference in a new issue