from reports.runner import REPORT_TYPE_LABELS def serialize_saved_report(row) -> dict: return { "id": str(row.id) if row.id else None, "name": row.name, "description": row.description, "report_type": row.report_type, "report_label": REPORT_TYPE_LABELS.get(row.report_type, row.report_type), "filters": row.filters or {}, "last_run_at": row.last_run_at.isoformat() if row.last_run_at else None, "created_at": row.created_at.isoformat() if row.created_at else None, "updated_at": row.updated_at.isoformat() if row.updated_at else None, } def serialize_report_run(row) -> dict: return { "id": str(row.id) if row.id else None, "saved_report_id": str(row.saved_report_id) if row.saved_report_id else None, "run_at": row.run_at.isoformat() if row.run_at else None, "params": row.params or {}, "row_count": int(row.row_count or 0), "status": row.status, }