-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: restaurant extractor service has been completed.
- Loading branch information
Showing
4 changed files
with
33 additions
and
5 deletions.
There are no files selected for viewing
20 changes: 18 additions & 2 deletions
20
src/recommendation_engine/app/features/restaurants/services/extraction.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,29 @@ | ||
from typing import List | ||
|
||
from ..domain.values import GeoValue | ||
from ....shared_kernel.extractor import Extractor | ||
from ..domain.entity.getir import GetirRestaurants | ||
from ..domain.values.restaurant import RestaurantValue | ||
from ....shared_kernel.domain_providers import Providers | ||
from ..domain.entity.yemek_sepeti import YemeksepetiRestaurants | ||
|
||
|
||
class RestaurantExtractorService(Extractor): | ||
def __init__(self, lat: float, lon: float): | ||
def __init__(self, provider_type: Providers, lat: float, lon: float): | ||
self.lat = lat | ||
self.lon = lon | ||
self.provider = self.initialize_provider(provider_type) | ||
|
||
def initialize_provider( | ||
self, provider_type: Providers | ||
) -> YemeksepetiRestaurants | GetirRestaurants: | ||
geo_value = GeoValue(lat=self.lat, lon=self.lon) | ||
if provider_type == Providers.YEMEK_SEPETI: | ||
return YemeksepetiRestaurants(geo_value) | ||
elif provider_type == Providers.GETIR: | ||
return GetirRestaurants(geo_value) | ||
else: | ||
ValueError("Provider is not defined.") | ||
|
||
def crawl(self) -> List[RestaurantValue]: | ||
pass | ||
return self.provider.process() |
6 changes: 6 additions & 0 deletions
6
src/recommendation_engine/app/shared_kernel/domain_providers.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from enum import Enum | ||
|
||
|
||
class Providers(Enum): | ||
GETIR = "GETIR" | ||
YEMEK_SEPETI = "YEMEK_SEPETI" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters