Skip to content

Commit

Permalink
added string check
Browse files Browse the repository at this point in the history
previous pr was failing with valueerror since some sites send an
empty string back so now there is a is digit check as well as fixing
some commenting
  • Loading branch information
LTDakin committed Dec 21, 2023
1 parent 33ed185 commit 3abd958
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions api/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,14 +291,17 @@ def filtered_images_query(db_address: str, query_filters: list):
image_pkgs = filter_img_pkgs_final_sstack(image_pkgs)
return image_pkgs

# Filter smart stacks to reduce the size of ui payload
# Filter out intermediate smart stacks to reduce the size of ui payload
def filter_img_pkgs_final_sstack(image_pkgs):
# dict containing max stknum for each unique smartstack
max_sstk_nums = {}

for img_pkg in image_pkgs:
if not img_pkg.get('SSTKNUM', 0).isdigit():
continue

smart_stk = img_pkg.get('SMARTSTK')
sstk_num = int(img_pkg.get('SSTKNUM'), 0)
sstk_num = int(img_pkg.get('SSTKNUM', 0))

if smart_stk is None or smart_stk == 'no':
continue
Expand All @@ -312,6 +315,7 @@ def filter_img_pkgs_final_sstack(image_pkgs):
if img_pkg.get('SMARTSTK') is None
or img_pkg.get('SSTKNUM') is None
or img_pkg.get('SMARTSTK') == 'no'
or not img_pkg.get('SMARTSTK').isdigit()
or int(img_pkg.get('SSTKNUM', 0)) >= max_sstk_nums.get(img_pkg.get('SMARTSTK'), 0)
]

Expand Down

0 comments on commit 3abd958

Please sign in to comment.