Additional checks, if bf api is not accessible

This commit is contained in:
avollkopf 2024-06-30 12:13:46 +02:00
parent 598f1e9dce
commit 607a403a8c
2 changed files with 21 additions and 22 deletions

View file

@ -1,3 +1,3 @@
__version__ = "4.4.2.a5" __version__ = "4.4.2.a6"
__codename__ = "Yeast Starter" __codename__ = "Yeast Starter"

View file

@ -101,9 +101,8 @@ class UploadController:
except Exception as e: except Exception as e:
logging.error(e) logging.error(e)
repeat = False repeat = False
try:
if bf_recipe_list: if bf_recipe_list:
#loop +=1
for row in bf_recipe_list: for row in bf_recipe_list:
recipe_id = row['_id'] recipe_id = row['_id']
name = row['name'] name = row['name']
@ -111,26 +110,26 @@ class UploadController:
result.append(element) result.append(element)
else: else:
repeat = False repeat = False
except Exception as e:
logging.error(e)
try:
if len(bf_recipe_list) != limit: if len(bf_recipe_list) != limit:
#logging.info(loop)
repeat = False repeat = False
else: else:
parameters={"limit": limit, 'start_after': recipe_id} parameters={"limit": limit, 'start_after': recipe_id}
except Exception as e:
logging.error(e)
try: try:
newlist = sorted(result, key=lambda d: d['label']) newlist = sorted(result, key=lambda d: d['label'])
listlength=len(newlist) listlength=len(newlist)
max=math.floor(listlength/length) max=math.floor(listlength/length)
#logging.error(listlength)
#logging.error(length)
sortlist=[] sortlist=[]
for i in range(0 , max+1): for i in range(0 , max+1):
sortlist.append({ 'value': i*length, 'label': i*length }) sortlist.append({ 'value': i*length, 'label': i*length })
#logging.error(sortlist)
return newlist, sortlist, length return newlist, sortlist, length
except: except:
logging.error("Return empty BF recipe list")
sortlist=[{ 'value': 0, 'label': '0' }] sortlist=[{ 'value': 0, 'label': '0' }]
return result, sortlist, length return result, sortlist, length