fix: handle datetime/Decimal objects in SEO audit JSONB serialization
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
SEOAuditor result dict contains datetime objects that can't be serialized to JSONB. Added _make_json_safe() to recursively convert them. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
9989e6fcb7
commit
0c878e38b9
@ -8,7 +8,8 @@ Tracks results over time for before/after comparison.
|
||||
|
||||
import logging
|
||||
import json
|
||||
from datetime import datetime
|
||||
from datetime import datetime, date
|
||||
from decimal import Decimal
|
||||
|
||||
from flask import abort, render_template, request, redirect, url_for, flash, jsonify
|
||||
from flask_login import login_required, current_user
|
||||
@ -22,6 +23,19 @@ logger = logging.getLogger(__name__)
|
||||
PORTAL_URL = 'https://nordabiznes.pl'
|
||||
|
||||
|
||||
def _make_json_safe(obj):
|
||||
"""Recursively convert datetime/Decimal objects to JSON-serializable types."""
|
||||
if isinstance(obj, dict):
|
||||
return {k: _make_json_safe(v) for k, v in obj.items()}
|
||||
elif isinstance(obj, list):
|
||||
return [_make_json_safe(v) for v in obj]
|
||||
elif isinstance(obj, (datetime, date)):
|
||||
return obj.isoformat()
|
||||
elif isinstance(obj, Decimal):
|
||||
return float(obj)
|
||||
return obj
|
||||
|
||||
|
||||
@bp.route('/portal-seo')
|
||||
@login_required
|
||||
def admin_portal_seo():
|
||||
@ -109,8 +123,8 @@ def admin_portal_seo_run():
|
||||
page_size_bytes=on_page.get('page_size_bytes'),
|
||||
image_count=on_page.get('total_images'),
|
||||
images_without_alt=on_page.get('images_without_alt'),
|
||||
# Full data
|
||||
full_results=result,
|
||||
# Full data (sanitize for JSONB - datetime/Decimal not serializable)
|
||||
full_results=_make_json_safe(result),
|
||||
notes=request.form.get('notes', ''),
|
||||
created_by=current_user.email
|
||||
)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user