Fix popularity metrics on list repos API
This commit is contained in:
parent
6bde6406c9
commit
e252ee07cb
4 changed files with 18 additions and 11 deletions
|
@ -187,7 +187,7 @@ def unstar_repository(user, repository):
|
|||
def get_user_starred_repositories(user):
|
||||
""" Retrieves all of the repositories a user has starred. """
|
||||
query = (Repository
|
||||
.select(Repository, User, Visibility)
|
||||
.select(Repository, User, Visibility, Repository.id.alias('rid'))
|
||||
.join(Star)
|
||||
.switch(Repository)
|
||||
.join(User)
|
||||
|
@ -233,11 +233,11 @@ def get_visible_repositories(username, namespace=None, include_public=False):
|
|||
if not include_public and not username:
|
||||
# Short circuit by returning a query that will find no repositories. We need to return a query
|
||||
# here, as it will be modified by other queries later on.
|
||||
return Repository.select().where(Repository.id == -1)
|
||||
return Repository.select(Repository.id.alias('rid')).where(Repository.id == -1)
|
||||
|
||||
query = (Repository
|
||||
.select(Repository.name, Repository.id.alias('rid'), Repository.description, Namespace.username,
|
||||
Repository.visibility)
|
||||
.select(Repository.name, Repository.id.alias('rid'),
|
||||
Repository.description, Namespace.username, Repository.visibility)
|
||||
.distinct()
|
||||
.switch(Repository)
|
||||
.join(Namespace, on=(Repository.namespace_user == Namespace.id))
|
||||
|
|
Reference in a new issue