Refactor and enhance logging in webhook handlers and Redis client
- Translated comments and docstrings from German to English for better clarity. - Improved logging consistency across various webhook handlers for create, delete, and update operations. - Centralized logging functionality by utilizing a dedicated logger utility. - Added new enums for file and XAI sync statuses in models. - Updated Redis client factory to use a centralized logger and improved error handling. - Enhanced API responses to include more descriptive messages and status codes.
This commit is contained in:
@@ -207,16 +207,15 @@ class BeteiligteSync:
|
||||
except:
|
||||
pass
|
||||
|
||||
@staticmethod
|
||||
def parse_timestamp(ts: Any) -> Optional[datetime]:
|
||||
def parse_timestamp(self, ts: Any) -> Optional[datetime]:
|
||||
"""
|
||||
Parse verschiedene Timestamp-Formate zu datetime
|
||||
Parse various timestamp formats to datetime.
|
||||
|
||||
Args:
|
||||
ts: String, datetime oder None
|
||||
ts: String, datetime or None
|
||||
|
||||
Returns:
|
||||
datetime-Objekt oder None
|
||||
datetime object or None
|
||||
"""
|
||||
if not ts:
|
||||
return None
|
||||
@@ -225,13 +224,13 @@ class BeteiligteSync:
|
||||
return ts
|
||||
|
||||
if isinstance(ts, str):
|
||||
# EspoCRM Format: "2026-02-07 14:30:00"
|
||||
# Advoware Format: "2026-02-07T14:30:00" oder "2026-02-07T14:30:00Z"
|
||||
# EspoCRM format: "2026-02-07 14:30:00"
|
||||
# Advoware format: "2026-02-07T14:30:00" or "2026-02-07T14:30:00Z"
|
||||
try:
|
||||
# Entferne trailing Z falls vorhanden
|
||||
# Remove trailing Z if present
|
||||
ts = ts.rstrip('Z')
|
||||
|
||||
# Versuche verschiedene Formate
|
||||
# Try various formats
|
||||
for fmt in [
|
||||
'%Y-%m-%d %H:%M:%S',
|
||||
'%Y-%m-%dT%H:%M:%S',
|
||||
@@ -242,11 +241,11 @@ class BeteiligteSync:
|
||||
except ValueError:
|
||||
continue
|
||||
|
||||
# Fallback: ISO-Format
|
||||
# Fallback: ISO format
|
||||
return datetime.fromisoformat(ts)
|
||||
|
||||
except Exception as e:
|
||||
logger.warning(f"Konnte Timestamp nicht parsen: {ts} - {e}")
|
||||
self._log(f"Could not parse timestamp: {ts} - {e}", level='warning')
|
||||
return None
|
||||
|
||||
return None
|
||||
|
||||
Reference in New Issue
Block a user