HACK: Don't join on the visibility table because it is horrendously slow for some odd reason.
This commit is contained in:
parent
eddcc02ea6
commit
079289c53c
1 changed files with 13 additions and 3 deletions
|
@ -823,8 +823,10 @@ def _filter_to_repos_for_user(query, username=None, namespace=None,
|
|||
if namespace:
|
||||
where_clause = where_clause & (Namespace.username == namespace)
|
||||
|
||||
# TODO(jschorr, jake): Figure out why the old join on Visibility was so darn slow and
|
||||
# remove this hack.
|
||||
if include_public:
|
||||
new_clause = (Visibility.name == 'public')
|
||||
new_clause = (Repository.visibility == _get_public_repo_visibility())
|
||||
if where_clause:
|
||||
where_clause = where_clause | new_clause
|
||||
else:
|
||||
|
@ -833,6 +835,16 @@ def _filter_to_repos_for_user(query, username=None, namespace=None,
|
|||
return query.where(where_clause)
|
||||
|
||||
|
||||
_public_repo_visibility_cache = None
|
||||
def _get_public_repo_visibility():
|
||||
global _public_repo_visibility_cache
|
||||
|
||||
if not _public_repo_visibility_cache:
|
||||
_public_repo_visibility_cache = Visibility.get(name='public')
|
||||
|
||||
return _public_repo_visibility_cache
|
||||
|
||||
|
||||
def get_matching_repositories(repo_term, username=None):
|
||||
namespace_term = repo_term
|
||||
name_term = repo_term
|
||||
|
@ -1224,8 +1236,6 @@ def find_create_or_link_image(docker_image_id, repository, username, translation
|
|||
.join(ImageStorage)
|
||||
.switch(Image)
|
||||
.join(Repository)
|
||||
.join(Visibility)
|
||||
.switch(Repository)
|
||||
.join(RepositoryPermission, JOIN_LEFT_OUTER)
|
||||
.switch(Repository)
|
||||
.join(Namespace, on=(Repository.namespace_user == Namespace.id))
|
||||
|
|
Reference in a new issue