From dd5d845185628d691e654577eb6b94e574127041 Mon Sep 17 00:00:00 2001 From: Angel Dijoux <77701490+Angel-Dijoux@users.noreply.github.com> Date: Mon, 1 Jan 2024 18:28:42 +0100 Subject: [PATCH] [Fix] `get_raw_data` in onisep search (#24) fix: `get_raw_data` in onisep --- src/business_logic/formation/scrap/get_main_formation.py | 4 ++-- src/business_logic/formation/scrap/search_formation.py | 4 ++-- .../formation/scrap/utils/get_onisep_data.py | 7 ++----- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/business_logic/formation/scrap/get_main_formation.py b/src/business_logic/formation/scrap/get_main_formation.py index 745e662..5596620 100644 --- a/src/business_logic/formation/scrap/get_main_formation.py +++ b/src/business_logic/formation/scrap/get_main_formation.py @@ -9,7 +9,7 @@ def get_main_formations(limit: int = 10, offset: int = None) -> FormationsWithTotal: - data = get_raw_data(limit, offset) + data = get_raw_data(limit=limit, offset=offset) formated_formations = format_formations(data["results"]) @@ -19,7 +19,7 @@ def get_main_formations(limit: int = 10, offset: int = None) -> FormationsWithTo def auth_get_main_formations( user_id: int, limit: int = 10, offset: int = None ) -> FormationsWithTotal: - data = get_raw_data(limit, offset) + data = get_raw_data(limit=limit, offset=offset) formated_formations = format_formation_with_is_favorite(user_id, data["results"]) diff --git a/src/business_logic/formation/scrap/search_formation.py b/src/business_logic/formation/scrap/search_formation.py index 72f249f..608ae54 100644 --- a/src/business_logic/formation/scrap/search_formation.py +++ b/src/business_logic/formation/scrap/search_formation.py @@ -11,7 +11,7 @@ def search_formations( query: str, limit: int, offset: int = None ) -> FormationsWithTotal: - data = get_raw_data(query, limit, offset) + data = get_raw_data(limit=limit, offset=offset, query=query) formated_formations = format_formations(data["results"]) @@ -21,7 +21,7 @@ def search_formations( def auth_search_formations( user_id: int, query: str, limit: int, offset: int = None ) -> FormationsWithTotal: - data = get_raw_data(query, limit, offset) + data = get_raw_data(limit=limit, offset=offset, query=query) formated_formations = format_formation_with_is_favorite(user_id, data["results"]) return FormationsWithTotal(data["total"], formated_formations) diff --git a/src/business_logic/formation/scrap/utils/get_onisep_data.py b/src/business_logic/formation/scrap/utils/get_onisep_data.py index 91ac1c3..af99bf2 100644 --- a/src/business_logic/formation/scrap/utils/get_onisep_data.py +++ b/src/business_logic/formation/scrap/utils/get_onisep_data.py @@ -45,17 +45,14 @@ def get_onisep_data(params: str) -> dict: def get_raw_data( - query: str = None, limit: int = 10, offset: int = None, - is_main_formations: bool = True, + query: str = None, ) -> dict: - if is_main_formations: + if not query: params = f"/search?&size={limit}" else: params = f"/search?q={query}&size={limit}" - if offset: params += f"&from={offset}" - return get_onisep_data(params)