diff --git a/app/services/filter_service.py b/app/services/filter_service.py index fe09fa1..027e1f5 100644 --- a/app/services/filter_service.py +++ b/app/services/filter_service.py @@ -28,10 +28,10 @@ def filter_by_date(announcements: List[Dict[str, Any]], pub_date = ann.get("publish_date") if not pub_date: continue - if isinstance(pub_date, date): - pub_date = pub_date - else: - pub_date = pub_date.date() if hasattr(pub_date, "date") else pub_date + if not isinstance(pub_date, date): + pub_date = pub_date.date() if hasattr(pub_date, "date") else None + if pub_date is None: + continue if start_date and pub_date < start_date: continue diff --git a/app/services/pipeline.py b/app/services/pipeline.py index ff3287f..e0a2b35 100644 --- a/app/services/pipeline.py +++ b/app/services/pipeline.py @@ -1,6 +1,6 @@ from typing import Any, Dict, List from app.crawler.base import PipelineConfig, PipelineResult -from app.services.filter_service import filter_by_keywords, dedup_by_hash +from app.services.filter_service import dedup_by_hash class PostCrawlPipeline: @@ -74,7 +74,7 @@ class PostCrawlPipeline: result_proxy = await self.db.execute(stmt) await self.db.commit() - return result_proxy.rowcount or len(values) + return result_proxy.rowcount if result_proxy.rowcount >= 0 else len(values) async def _send_notifications(self, announcements: List[Dict[str, Any]]) -> int: return await self.notify.send(announcements)