fix: handle timezone-aware datetime in freshness checker
Some checks are pending
NordaBiz Tests / Unit & Integration Tests (push) Waiting to run
NordaBiz Tests / E2E Tests (Playwright) (push) Blocked by required conditions
NordaBiz Tests / Smoke Tests (Production) (push) Blocked by required conditions
NordaBiz Tests / Send Failure Notification (push) Blocked by required conditions
Some checks are pending
NordaBiz Tests / Unit & Integration Tests (push) Waiting to run
NordaBiz Tests / E2E Tests (Playwright) (push) Blocked by required conditions
NordaBiz Tests / Smoke Tests (Production) (push) Blocked by required conditions
NordaBiz Tests / Send Failure Notification (push) Blocked by required conditions
parsedate_to_datetime returns offset-aware datetime from Last-Modified header, but datetime.now() is naive. Strip tzinfo before subtraction. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
d6b7e9ac54
commit
1a352f2e0d
@ -433,12 +433,20 @@ class ContentFreshnessChecker:
|
|||||||
except Exception:
|
except Exception:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if latest_date and (result['last_content_update'] is None or latest_date > result['last_content_update']):
|
if latest_date:
|
||||||
result['last_content_update'] = latest_date
|
existing = result['last_content_update']
|
||||||
|
if existing is not None and existing.tzinfo is not None:
|
||||||
|
existing = existing.replace(tzinfo=None)
|
||||||
|
if existing is None or latest_date > existing:
|
||||||
|
result['last_content_update'] = latest_date
|
||||||
|
|
||||||
# Calculate freshness score
|
# Calculate freshness score
|
||||||
if result['last_content_update']:
|
if result['last_content_update']:
|
||||||
days_old = (datetime.now() - result['last_content_update']).days
|
update_dt = result['last_content_update']
|
||||||
|
# Normalize: strip tzinfo if present so subtraction works with naive datetime.now()
|
||||||
|
if update_dt.tzinfo is not None:
|
||||||
|
update_dt = update_dt.replace(tzinfo=None)
|
||||||
|
days_old = (datetime.now() - update_dt).days
|
||||||
if days_old <= 30:
|
if days_old <= 30:
|
||||||
result['content_freshness_score'] = 100
|
result['content_freshness_score'] = 100
|
||||||
elif days_old <= 90:
|
elif days_old <= 90:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user