fix: 修复 filter_by_date 类型处理 + _save_to_db rowcount 0 值 bug
This commit is contained in:
@@ -28,10 +28,10 @@ def filter_by_date(announcements: List[Dict[str, Any]],
|
|||||||
pub_date = ann.get("publish_date")
|
pub_date = ann.get("publish_date")
|
||||||
if not pub_date:
|
if not pub_date:
|
||||||
continue
|
continue
|
||||||
if isinstance(pub_date, date):
|
if not isinstance(pub_date, date):
|
||||||
pub_date = pub_date
|
pub_date = pub_date.date() if hasattr(pub_date, "date") else None
|
||||||
else:
|
if pub_date is None:
|
||||||
pub_date = pub_date.date() if hasattr(pub_date, "date") else pub_date
|
continue
|
||||||
|
|
||||||
if start_date and pub_date < start_date:
|
if start_date and pub_date < start_date:
|
||||||
continue
|
continue
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
from typing import Any, Dict, List
|
from typing import Any, Dict, List
|
||||||
from app.crawler.base import PipelineConfig, PipelineResult
|
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:
|
class PostCrawlPipeline:
|
||||||
@@ -74,7 +74,7 @@ class PostCrawlPipeline:
|
|||||||
|
|
||||||
result_proxy = await self.db.execute(stmt)
|
result_proxy = await self.db.execute(stmt)
|
||||||
await self.db.commit()
|
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:
|
async def _send_notifications(self, announcements: List[Dict[str, Any]]) -> int:
|
||||||
return await self.notify.send(announcements)
|
return await self.notify.send(announcements)
|
||||||
|
|||||||
Reference in New Issue
Block a user