Switch get repo API to use a single list tags query

Should make things faster since the join occurs on the database side
This commit is contained in:
Joseph Schorr 2017-04-13 16:34:14 -04:00
parent d86b0254b3
commit ab2f044331
4 changed files with 48 additions and 15 deletions

View file

@ -322,7 +322,7 @@ class Repository(RepositoryParamResource):
return repo_data
# Older image-only repo code.
def tag_view(tag, manifest):
def tag_view(tag):
tag_info = {
'name': tag.name,
'image_id': tag.image.docker_image_id,
@ -333,16 +333,14 @@ class Repository(RepositoryParamResource):
last_modified = format_date(datetime.fromtimestamp(tag.lifetime_start_ts))
tag_info['last_modified'] = last_modified
if manifest is not None:
tag_info['manifest_digest'] = manifest.digest
if tag.tagmanifest is not None:
tag_info['manifest_digest'] = tag.tagmanifest.digest
return tag_info
stats = None
tags = model.tag.list_repository_tags(namespace, repository, include_storage=True)
manifests = model.tag.get_tag_manifests(tags)
tag_dict = {tag.name: tag_view(tag, manifests.get(tag.id)) for tag in tags}
tags = model.tag.list_active_repo_tags(repo)
tag_dict = {tag.name: tag_view(tag) for tag in tags}
if parsed_args['includeStats']:
stats = []
found_dates = {}
@ -419,7 +417,7 @@ class Repository(RepositoryParamResource):
# Remove any builds from the queue.
dockerfile_build_queue.delete_namespaced_items(namespace, repository)
log_action('delete_repo', namespace,
{'repo': repository, 'namespace': namespace})
return '', 204