From c47c1a7e77be04a27bc6ab08d7a91cf7e0a09ed1 Mon Sep 17 00:00:00 2001 From: Yariv Menachem Date: Tue, 17 Dec 2024 19:53:35 +0200 Subject: [PATCH] filter by choice and hours works --- .../scrapers/goozali/GoozaliScrapperComponent.py | 6 ++++++ src/tests/test_goozali.py | 15 ++++++++++----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/jobspy/scrapers/goozali/GoozaliScrapperComponent.py b/src/jobspy/scrapers/goozali/GoozaliScrapperComponent.py index e6bdf4b..dc0788d 100644 --- a/src/jobspy/scrapers/goozali/GoozaliScrapperComponent.py +++ b/src/jobspy/scrapers/goozali/GoozaliScrapperComponent.py @@ -16,6 +16,12 @@ class GoozaliScrapperComponent: pass # Function to filter GoozaliRows based on hours old + def filter_rows_by_column_choice(self, rows: list[GoozaliRow], column: GoozaliColumn, column_choice: GoozaliColumnChoice) -> list[GoozaliRow]: + return [ + row for row in rows + if row.cellValuesByColumnId[column.id] == column_choice.id + ] + def filter_rows_by_hours(self, rows: list[GoozaliRow], hours: int) -> list[GoozaliRow]: # Current time now = datetime.now() diff --git a/src/tests/test_goozali.py b/src/tests/test_goozali.py index 04e81ec..91f8da8 100644 --- a/src/tests/test_goozali.py +++ b/src/tests/test_goozali.py @@ -24,11 +24,16 @@ try: component = GoozaliScrapperComponent() hours_old = 200 - field_cloumn = component.find_column(response_data.columns, "Field") - software_engineering_choice = component.find_choice_from_column( - field_cloumn, "Software Engineering") - filtered_rows_by_age = component.filter_rows_by_hours( - response_data.rows, hours_old) + column = component.find_column(response_data.columns, "Field") + column_choice = component.find_choice_from_column( + column, "Software Engineering") + + filtered_rows_by_column_choice = component.filter_rows_by_column_choice( + response_data.rows, column, column_choice) + filtered_rows_by_age_and_column_choice = component.filter_rows_by_hours( + filtered_rows_by_column_choice, hours_old) + + filtered_rows_by_age_and_column_choice except FileNotFoundError: print("The file was not found.") except json.JSONDecodeError: