From 76b734b0a9bac933c95dc0515d7a89f9b8bf0e32 Mon Sep 17 00:00:00 2001 From: v6ole Date: Sat, 9 May 2026 14:06:59 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20filter=5Fby=5Fdate?= =?UTF-8?q?=20=E7=B1=BB=E5=9E=8B=E5=A4=84=E7=90=86=20+=20=5Fsave=5Fto=5Fdb?= =?UTF-8?q?=20rowcount=200=20=E5=80=BC=20bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/filter_service.py | 8 ++++---- app/services/pipeline.py | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) 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)