mirror of
https://github.com/PiBrewing/craftbeerpi4.git
synced 2024-12-22 13:34:55 +01:00
Added offset to bf recipe list -> up to 250 recipes can be selected
This commit is contained in:
parent
f62263e287
commit
c8c6491467
2 changed files with 5 additions and 5 deletions
|
@ -58,7 +58,7 @@ class UploadController:
|
|||
except:
|
||||
return []
|
||||
|
||||
async def get_brewfather_recipes(self):
|
||||
async def get_brewfather_recipes(self,offset=0):
|
||||
brewfather = True
|
||||
result=[]
|
||||
self.url="https://api.brewfather.app/v1/recipes"
|
||||
|
@ -73,7 +73,7 @@ class UploadController:
|
|||
if brewfather == True:
|
||||
encodedData = base64.b64encode(bytes(f"{brewfather_user_id}:{brewfather_api_key}", "ISO-8859-1")).decode("ascii")
|
||||
headers={"Authorization": "Basic %s" % encodedData}
|
||||
parameters={"limit": 50}
|
||||
parameters={"limit": 50, 'offset': offset}
|
||||
async with aiohttp.ClientSession(headers=headers) as bf_session:
|
||||
async with bf_session.get(self.url, params=parameters) as r:
|
||||
bf_recipe_list = await r.json()
|
||||
|
|
|
@ -101,7 +101,7 @@ class UploadHttpEndpoints():
|
|||
await self.controller.xml_recipe_creation(xml_id['id'])
|
||||
return web.Response(status=200)
|
||||
|
||||
@request_mapping(path='/bf', method="GET", auth_required=False)
|
||||
@request_mapping(path='/bf/{offset}/', method="POST", auth_required=False)
|
||||
async def get_bf_list(self, request):
|
||||
"""
|
||||
|
||||
|
@ -113,8 +113,8 @@ class UploadHttpEndpoints():
|
|||
"200":
|
||||
description: successful operation
|
||||
"""
|
||||
|
||||
bf_list = await self.controller.get_brewfather_recipes()
|
||||
offset = request.match_info['offset']
|
||||
bf_list = await self.controller.get_brewfather_recipes(offset)
|
||||
|
||||
return web.json_response(bf_list)
|
||||
|
||||
|
|
Loading…
Reference in a new issue