Fix crawled_at type error in get_channel
SQLite returns datetime columns as strings via raw text() queries. Parse crawled_at safely before comparing against utcnow(). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -579,11 +579,17 @@ def get_channel(
|
|||||||
raise HTTPException(status_code=404, detail="Channel not found")
|
raise HTTPException(status_code=404, detail="Channel not found")
|
||||||
|
|
||||||
# Re-index in the background if stale (not crawled in the last hour)
|
# Re-index in the background if stale (not crawled in the last hour)
|
||||||
crawled_at = row.get("crawled_at")
|
stale = True
|
||||||
stale = (
|
try:
|
||||||
crawled_at is None
|
crawled_at_raw = row.get("crawled_at")
|
||||||
or (datetime.utcnow() - crawled_at).total_seconds() > 3600
|
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:
|
if stale:
|
||||||
background_tasks.add_task(_index_channel_task, channel_id, current_user.id)
|
background_tasks.add_task(_index_channel_task, channel_id, current_user.id)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user