Skip to content

Commit

Permalink
feat: yemeksepeti restaurant value was completed.
Browse files Browse the repository at this point in the history
  • Loading branch information
fmelihh committed May 19, 2024
1 parent 5a94e40 commit 612ba81
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/recommendation_engine/app/domain/processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def process(self, process_limit: int | None = None) -> T:
@staticmethod
def _retrieve_json_from_response(response: requests.Response) -> dict | None:
try:
return response.json()
return response.json() if isinstance(response, requests.Response) else None
except Exception as e:
logger.exception(
f"given response object cannot be jsonable. url: {response.url}. error details: {e}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
@dataclass(frozen=True)
class YemeksepetiRestaurantValue(RestaurantValue):
name: str
rating: int | None
rating: float | int | None
url_slug: str
restaurant_id: str
restaurant_id: str | int | float
review_number: int | None
coordinates: GeoValue | dict | None
minimum_pickup_time: float | None
Expand All @@ -27,7 +27,7 @@ def validate_name(self) -> str:
return self.name

def validate_rating(self) -> int | None:
if self.rating and not isinstance(self.rating, int):
if self.rating and not isinstance(self.rating, (int, float)):
raise ValueError("invalid rating type expected.")
return self.rating

Expand All @@ -37,9 +37,9 @@ def validate_url_slug(self) -> str:
return self.url_slug

def validate_restaurant_id(self) -> str:
if not isinstance(self.restaurant_id, str):
if not self.restaurant_id:
raise ValueError("invalid restaurant_id type expected.")
return self.restaurant_id
return str(self.restaurant_id)

def validate_review_number(self) -> int | None:
if self.review_number and not isinstance(self.review_number, int):
Expand Down

0 comments on commit 612ba81

Please sign in to comment.