Skip to content

Commit

Permalink
Additional checks, if bf api is not accessible
Browse files Browse the repository at this point in the history
  • Loading branch information
avollkopf committed Jun 30, 2024
1 parent 598f1e9 commit 607a403
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 22 deletions.
2 changes: 1 addition & 1 deletion cbpi/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
__version__ = "4.4.2.a5"
__version__ = "4.4.2.a6"
__codename__ = "Yeast Starter"

41 changes: 20 additions & 21 deletions cbpi/controller/upload_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,36 +101,35 @@ async def get_brewfather_recipes(self,offset=0):
except Exception as e:
logging.error(e)
repeat = False

if bf_recipe_list:
#loop +=1
for row in bf_recipe_list:
recipe_id = row['_id']
name = row['name']
element = {'value': recipe_id, 'label': name}
result.append(element)
else:
repeat = False

if len(bf_recipe_list) != limit:
#logging.info(loop)
repeat = False
else:
parameters={"limit": limit, 'start_after': recipe_id}


try:
if bf_recipe_list:
for row in bf_recipe_list:
recipe_id = row['_id']
name = row['name']
element = {'value': recipe_id, 'label': name}
result.append(element)
else:
repeat = False
except Exception as e:
logging.error(e)
try:
if len(bf_recipe_list) != limit:
repeat = False
else:
parameters={"limit": limit, 'start_after': recipe_id}
except Exception as e:
logging.error(e)

try:
newlist = sorted(result, key=lambda d: d['label'])
listlength=len(newlist)
max=math.floor(listlength/length)
#logging.error(listlength)
#logging.error(length)
sortlist=[]
for i in range(0 , max+1):
sortlist.append({ 'value': i*length, 'label': i*length })
#logging.error(sortlist)
return newlist, sortlist, length
except:
logging.error("Return empty BF recipe list")
sortlist=[{ 'value': 0, 'label': '0' }]
return result, sortlist, length

Expand Down

0 comments on commit 607a403

Please sign in to comment.