Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
erlichsefi committed Nov 22, 2024
1 parent 70852e6 commit 0ca80ba
Showing 1 changed file with 28 additions and 16 deletions.
44 changes: 28 additions & 16 deletions il_supermarket_scarper/scraper_stability.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from enum import Enum
import datetime
from il_supermarket_scarper.utils import _is_saturday_in_israel, _now, FileTypesFilters


Expand All @@ -19,6 +20,11 @@ def executes_between_midnight_and_morning_and_requested_today(
and when_date.date() == execution_time.date()
)

@classmethod
def executed_after_date(cls, when_date, date):
"""check if executed after date"""
return when_date > date

@classmethod
def failire_valid(cls, when_date=None, **_):
"""return true if the parser is stble"""
Expand Down Expand Up @@ -76,23 +82,27 @@ def failire_valid(cls, when_date=None, **_):
)


class SalachDabach(FullyStable):
class CityMarketGivataim(FullyStable):
"""Netiv Hased is stablity"""

@classmethod
def searching_for_store(cls, files_types=None, **_):
def searching_for_update_promo(cls, files_types=None, **_):
"""if the execution is in saturday"""
return files_types and files_types == [FileTypesFilters.STORE_FILE.name]
return files_types and files_types == [FileTypesFilters.PROMO_FILE.name]

@classmethod
def failire_valid(cls, when_date=None, files_types=None, **_):
"""return true if the parser is stble"""
return super().failire_valid(when_date=when_date) or cls.searching_for_store(
files_types=files_types
return (
super().failire_valid(when_date=when_date)
or cls.searching_for_update_promo(files_types=files_types)
or cls.executed_after_date(
when_date=when_date, date=datetime.datetime(year=2024, month=11, day=5)
)
)


class CityMarketGivataim(FullyStable):
class CityMarketKiratOno(FullyStable):
"""Netiv Hased is stablity"""

@classmethod
Expand All @@ -108,48 +118,50 @@ def failire_valid(cls, when_date=None, files_types=None, **_):
) or cls.searching_for_update_promo(files_types=files_types)


class CityMarketKiratOno(FullyStable):
class CityMarketKiratGat(FullyStable):
"""Netiv Hased is stablity"""

@classmethod
def searching_for_update_promo(cls, files_types=None, **_):
def searching_for_update_promo_full(cls, files_types=None, **_):
"""if the execution is in saturday"""
return files_types and files_types == [FileTypesFilters.PROMO_FILE.name]
return files_types and files_types == [FileTypesFilters.PROMO_FULL_FILE.name]

@classmethod
def failire_valid(cls, when_date=None, files_types=None, **_):
"""return true if the parser is stble"""
return super().failire_valid(
when_date=when_date
) or cls.searching_for_update_promo(files_types=files_types)
) or cls.searching_for_update_promo_full(files_types=files_types)


class CityMarketKiratGat(FullyStable):
"""Netiv Hased is stablity"""
class DoNotPublishStores(FullyStable):
"""stablity for chains that doesn't pubish stores"""

@classmethod
def searching_for_update_promo_full(cls, files_types=None, **_):
def searching_for_store_full(cls, files_types=None, **_):
"""if the execution is in saturday"""
return files_types and files_types == [FileTypesFilters.PROMO_FULL_FILE.name]
return files_types and files_types == [FileTypesFilters.STORE_FILE.name]

@classmethod
def failire_valid(cls, when_date=None, files_types=None, **_):
"""return true if the parser is stble"""
return super().failire_valid(
when_date=when_date
) or cls.searching_for_update_promo_full(files_types=files_types)
) or cls.searching_for_store_full(files_types=files_types)


class ScraperStability(Enum):
"""tracker for the stablity of the scraper"""

COFIX = DoNotPublishStores
NETIV_HASED = NetivHased
QUIK = Quik
SALACH_DABACH = SalachDabach
SALACH_DABACH = DoNotPublishStores
CITY_MARKET_GIVATAYIM = CityMarketGivataim
CITY_MARKET_KIRYATONO = CityMarketKiratOno
CITY_MARKET_KIRYATGAT = CityMarketKiratGat
MESHMAT_YOSEF_1 = SuperFlaky
YOHANANOF = DoNotPublishStores

@classmethod
def is_validate_scraper_found_no_files(
Expand Down

0 comments on commit 0ca80ba

Please sign in to comment.