Fix indentation for DB queries.
This commit is contained in:
parent
1d8b72235a
commit
0815f6b6c4
2 changed files with 18 additions and 14 deletions
|
@ -192,10 +192,11 @@ def _get_repo_tag_image(tag_name, include_storage, modifier):
|
||||||
query = Image.select().join(RepositoryTag)
|
query = Image.select().join(RepositoryTag)
|
||||||
|
|
||||||
if include_storage:
|
if include_storage:
|
||||||
query = (Image.select(Image, ImageStorage)
|
query = (Image
|
||||||
.join(ImageStorage)
|
.select(Image, ImageStorage)
|
||||||
.switch(Image)
|
.join(ImageStorage)
|
||||||
.join(RepositoryTag))
|
.switch(Image)
|
||||||
|
.join(RepositoryTag))
|
||||||
|
|
||||||
images = _tag_alive(modifier(query.where(RepositoryTag.name == tag_name)))
|
images = _tag_alive(modifier(query.where(RepositoryTag.name == tag_name)))
|
||||||
if not images:
|
if not images:
|
||||||
|
@ -213,10 +214,11 @@ def get_repo_tag_image(repo, tag_name, include_storage=False):
|
||||||
|
|
||||||
def get_tag_image(namespace_name, repository_name, tag_name, include_storage=False):
|
def get_tag_image(namespace_name, repository_name, tag_name, include_storage=False):
|
||||||
def modifier(query):
|
def modifier(query):
|
||||||
return (query.switch(RepositoryTag)
|
return (query
|
||||||
.join(Repository)
|
.switch(RepositoryTag)
|
||||||
.join(Namespace)
|
.join(Repository)
|
||||||
.where(Namespace.username == namespace_name, Repository.name == repository_name))
|
.join(Namespace)
|
||||||
|
.where(Namespace.username == namespace_name, Repository.name == repository_name))
|
||||||
|
|
||||||
return _get_repo_tag_image(tag_name, include_storage, modifier)
|
return _get_repo_tag_image(tag_name, include_storage, modifier)
|
||||||
|
|
||||||
|
|
|
@ -183,9 +183,10 @@ class TestGarbageCollection(unittest.TestCase):
|
||||||
model.repository.purge_repository(repo.namespace_user.username, repo.name)
|
model.repository.purge_repository(repo.namespace_user.username, repo.name)
|
||||||
|
|
||||||
# Change the time machine expiration on the namespace.
|
# Change the time machine expiration on the namespace.
|
||||||
(database.User.update(removed_tag_expiration_s=1000000000)
|
(database.User
|
||||||
.where(database.User.username == ADMIN_ACCESS_USER)
|
.update(removed_tag_expiration_s=1000000000)
|
||||||
.execute())
|
.where(database.User.username == ADMIN_ACCESS_USER)
|
||||||
|
.execute())
|
||||||
|
|
||||||
# Create a repository without any garbage.
|
# Create a repository without any garbage.
|
||||||
repository = self.createRepository(latest=['i1', 'i2', 'i3'])
|
repository = self.createRepository(latest=['i1', 'i2', 'i3'])
|
||||||
|
@ -200,9 +201,10 @@ class TestGarbageCollection(unittest.TestCase):
|
||||||
self.assertIsNone(model.repository.find_repository_with_garbage(1000000000))
|
self.assertIsNone(model.repository.find_repository_with_garbage(1000000000))
|
||||||
|
|
||||||
# Change the time machine expiration on the namespace.
|
# Change the time machine expiration on the namespace.
|
||||||
(database.User.update(removed_tag_expiration_s=0)
|
(database.User
|
||||||
.where(database.User.username == ADMIN_ACCESS_USER)
|
.update(removed_tag_expiration_s=0)
|
||||||
.execute())
|
.where(database.User.username == ADMIN_ACCESS_USER)
|
||||||
|
.execute())
|
||||||
|
|
||||||
# Now we should find the repository for GC.
|
# Now we should find the repository for GC.
|
||||||
repository = model.repository.find_repository_with_garbage(0)
|
repository = model.repository.find_repository_with_garbage(0)
|
||||||
|
|
Reference in a new issue