From c8c64914673eebe348107fa03a0462b043914eba Mon Sep 17 00:00:00 2001 From: avollkopf <43980694+avollkopf@users.noreply.github.com> Date: Sun, 4 Jul 2021 17:42:37 +0200 Subject: [PATCH] Added offset to bf recipe list -> up to 250 recipes can be selected --- cbpi/controller/upload_controller.py | 4 ++-- cbpi/http_endpoints/http_upload.py | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cbpi/controller/upload_controller.py b/cbpi/controller/upload_controller.py index dacc243..94f46eb 100644 --- a/cbpi/controller/upload_controller.py +++ b/cbpi/controller/upload_controller.py @@ -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() diff --git a/cbpi/http_endpoints/http_upload.py b/cbpi/http_endpoints/http_upload.py index 9a24e0f..620684b 100644 --- a/cbpi/http_endpoints/http_upload.py +++ b/cbpi/http_endpoints/http_upload.py @@ -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)