Performance improvements for the repo API and the new repo UI
This commit is contained in:
parent
bc6baae050
commit
ab2331a486
9 changed files with 119 additions and 100 deletions
|
@ -17,7 +17,7 @@ def image_view(image, image_map):
|
|||
command = extended_props.command
|
||||
|
||||
def docker_id(aid):
|
||||
if not aid:
|
||||
if not aid or not aid in image_map:
|
||||
return ''
|
||||
|
||||
return image_map[aid]
|
||||
|
@ -51,19 +51,26 @@ class RepositoryImageList(RepositoryParamResource):
|
|||
all_tags = model.list_repository_tags(namespace, repository)
|
||||
|
||||
tags_by_image_id = defaultdict(list)
|
||||
found_image_ids = set()
|
||||
|
||||
for tag in all_tags:
|
||||
tags_by_image_id[tag.image.docker_image_id].append(tag.name)
|
||||
found_image_ids.add(str(tag.image.id))
|
||||
found_image_ids.update(tag.image.ancestors.split('/')[1:-1])
|
||||
|
||||
image_map = {}
|
||||
filtered_images = []
|
||||
for image in all_images:
|
||||
image_map[str(image.id)] = image.docker_image_id
|
||||
if str(image.id) in found_image_ids:
|
||||
image_map[str(image.id)] = image.docker_image_id
|
||||
filtered_images.append(image)
|
||||
|
||||
def add_tags(image_json):
|
||||
image_json['tags'] = tags_by_image_id[image_json['id']]
|
||||
return image_json
|
||||
|
||||
return {
|
||||
'images': [add_tags(image_view(image, image_map)) for image in all_images]
|
||||
'images': [add_tags(image_view(image, image_map)) for image in filtered_images]
|
||||
}
|
||||
|
||||
|
||||
|
|
Reference in a new issue