Skip to content

Commit 919f5de

Browse files
committed
fix to limit crawling 2 week items
1 parent 9312b5a commit 919f5de

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

pythonkr_backend/curation/tasks.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from celery import shared_task
66
import feedparser
77
import requests
8-
from datetime import datetime, timezone
8+
from datetime import datetime, timezone, timedelta
99
from django.utils import timezone as django_timezone
1010
from django.core.files.base import ContentFile
1111
from .models import RSSFeed, RSSItem
@@ -159,9 +159,11 @@ def crawl_rss_item_content():
159159
logfire.info("Starting RSS item content crawling")
160160
logger.info("Starting RSS item content crawling")
161161

162-
# 크롤링되지 않은 최신 1개 아이템 가져오기
162+
# 2주 이내의 크롤링되지 않은 최신 1개 아이템 가져오기
163+
two_weeks_ago = django_timezone.now() - timedelta(days=14)
163164
pending_item = RSSItem.objects.filter(
164-
crawling_status='pending'
165+
crawling_status='pending',
166+
pub_date__gte=two_weeks_ago
165167
).order_by('-pub_date', '-created_at').first()
166168

167169
if not pending_item:

0 commit comments

Comments
 (0)