Skip to content

Commit

Permalink
Added filter function to remove non smart stacks
Browse files Browse the repository at this point in the history
Created a filter function that is run on img_pkgs after fetched from s3
it keeps non smart stack images and images that are the final of a smart
stack. The goal of this change is to lower the download time for the ui
in the case that a session had lots of smart stacks.
  • Loading branch information
LTDakin committed Nov 17, 2023
1 parent c6d9c7d commit e56a7d4
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions api/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,17 @@ def filtered_images_query(db_address: str, query_filters: list):
.all()
session.expunge_all()
image_pkgs = [image.get_image_pkg() for image in images]
image_pkgs = list(filter(filter_img_pkgs_final_sstack, image_pkgs))
return image_pkgs

# Filter removes intermediate smart stacks to reduce the size of payload sent to the ui
def filter_img_pkgs_final_sstack(img_pkg):
try:
if img_pkg["SMARTSTK"] == 'no' or img_pkg["SMARTSTK"] == img_pkg["SSTKNUM"]:
return True
return False
except KeyError :
return True

def get_image_by_filename(db_address, base_filename):
"""Gets the image package for the image specified by the filename.
Expand Down

0 comments on commit e56a7d4

Please sign in to comment.