Skip to content

Commit

Permalink
[Fix] get_raw_data in onisep search (#24)
Browse files Browse the repository at this point in the history
fix: `get_raw_data` in onisep
  • Loading branch information
Angel-Dijoux authored Jan 1, 2024
1 parent 4e4362e commit dd5d845
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/business_logic/formation/scrap/get_main_formation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"])

Expand All @@ -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"])

Expand Down
4 changes: 2 additions & 2 deletions src/business_logic/formation/scrap/search_formation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"])

Expand All @@ -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)
7 changes: 2 additions & 5 deletions src/business_logic/formation/scrap/utils/get_onisep_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit dd5d845

Please sign in to comment.