Skip to content

Commit

Permalink
fix: 2일치에 대해서만 가격 업데이트를 하도록 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
BEMELON committed Jan 28, 2024
1 parent 7c40a80 commit 7ea8e6a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
from scrapy_crawler.common.db import Deal, get_engine
from scrapy_crawler.common.db.models import Trade
from scrapy_crawler.common.slack.SlackBots import ExceptionSlackBot
from scrapy_crawler.common.utils.helpers import init_cloudwatch_logger
from scrapy_crawler.common.utils.helpers import (
get_local_timestring,
init_cloudwatch_logger,
)


class PriceUpdateSpider(scrapy.Spider):
Expand Down Expand Up @@ -44,6 +47,7 @@ def get_soldout_items(self) -> List[Deal]:
self.session.query(Deal)
.filter(Deal.sold == true())
.filter(Deal.deleted_at == null())
.filter(Deal.last_crawled >= get_local_timestring(days=-1))
)
return item.all()

Expand Down
4 changes: 2 additions & 2 deletions scrapy_crawler/common/utils/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
from scrapy_crawler.DBWatchDog.items import IpadItem, IphoneItem, MacbookItem


def get_local_timestring() -> str:
return (datetime.now()).strftime("%Y-%m-%d %H:%M:%S")
def get_local_timestring(days: int = 0) -> str:
return (datetime.now() + timedelta(days=days)).strftime("%Y-%m-%d %H:%M:%S")


def get_timestamp() -> int:
Expand Down

0 comments on commit 7ea8e6a

Please sign in to comment.