diff --git a/backend/routers/channels.py b/backend/routers/channels.py index 6b06ac0..c522388 100644 --- a/backend/routers/channels.py +++ b/backend/routers/channels.py @@ -579,11 +579,17 @@ def get_channel( raise HTTPException(status_code=404, detail="Channel not found") # Re-index in the background if stale (not crawled in the last hour) - crawled_at = row.get("crawled_at") - stale = ( - crawled_at is None - or (datetime.utcnow() - crawled_at).total_seconds() > 3600 - ) + stale = True + try: + crawled_at_raw = row.get("crawled_at") + if crawled_at_raw: + crawled_at = ( + crawled_at_raw if isinstance(crawled_at_raw, datetime) + else datetime.fromisoformat(str(crawled_at_raw)) + ) + stale = (datetime.utcnow() - crawled_at).total_seconds() > 3600 + except Exception: + pass if stale: background_tasks.add_task(_index_channel_task, channel_id, current_user.id)