Fix: UTC fuer interne Timer, Berlin nur fuer Anzeige
Korrektur: Alle DB-Timestamps (refresh_log, created_at, updated_at, auth, notifications) bleiben UTC fuer korrekte Timer-Vergleiche. Europe/Berlin nur fuer angezeigte Werte (Exporte, Prompts, API). Verhindert zu fruehes Ausloesen des Auto-Refresh-Timers. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Dieser Commit ist enthalten in:
14
src/main.py
14
src/main.py
@@ -5,7 +5,7 @@ import logging
|
||||
import os
|
||||
import sys
|
||||
from contextlib import asynccontextmanager
|
||||
from datetime import datetime
|
||||
from datetime import datetime, timezone
|
||||
from typing import Dict
|
||||
|
||||
from fastapi import FastAPI, WebSocket, WebSocketDisconnect, Depends, Request, Response
|
||||
@@ -93,7 +93,7 @@ async def check_auto_refresh():
|
||||
)
|
||||
incidents = await cursor.fetchall()
|
||||
|
||||
now = datetime.now(TIMEZONE)
|
||||
now = datetime.now(timezone.utc)
|
||||
|
||||
for incident in incidents:
|
||||
incident_id = incident["id"]
|
||||
@@ -112,7 +112,7 @@ async def check_auto_refresh():
|
||||
else:
|
||||
last_time = datetime.fromisoformat(last_refresh["completed_at"])
|
||||
if last_time.tzinfo is None:
|
||||
last_time = last_time.replace(tzinfo=TIMEZONE)
|
||||
last_time = last_time.replace(tzinfo=timezone.utc)
|
||||
elapsed = (now - last_time).total_seconds() / 60
|
||||
if elapsed >= interval:
|
||||
should_refresh = True
|
||||
@@ -143,11 +143,11 @@ async def cleanup_expired():
|
||||
)
|
||||
incidents = await cursor.fetchall()
|
||||
|
||||
now = datetime.now(TIMEZONE)
|
||||
now = datetime.now(timezone.utc)
|
||||
for incident in incidents:
|
||||
created = datetime.fromisoformat(incident["created_at"])
|
||||
if created.tzinfo is None:
|
||||
created = created.replace(tzinfo=TIMEZONE)
|
||||
created = created.replace(tzinfo=timezone.utc)
|
||||
age_days = (now - created).days
|
||||
if age_days >= incident["retention_days"]:
|
||||
await db.execute(
|
||||
@@ -164,7 +164,7 @@ async def cleanup_expired():
|
||||
for orphan in orphans:
|
||||
started = datetime.fromisoformat(orphan["started_at"])
|
||||
if started.tzinfo is None:
|
||||
started = started.replace(tzinfo=TIMEZONE)
|
||||
started = started.replace(tzinfo=timezone.utc)
|
||||
age_minutes = (now - started).total_seconds() / 60
|
||||
if age_minutes >= 15:
|
||||
await db.execute(
|
||||
@@ -195,7 +195,7 @@ async def lifespan(app: FastAPI):
|
||||
try:
|
||||
result = await db.execute(
|
||||
"UPDATE refresh_log SET status = 'error', completed_at = ?, error_message = 'Verwaist (Neustart, automatisch bereinigt)' WHERE status = 'running'",
|
||||
(datetime.now(TIMEZONE).isoformat(),),
|
||||
(datetime.now(timezone.utc).strftime('%Y-%m-%d %H:%M:%S'),),
|
||||
)
|
||||
if result.rowcount > 0:
|
||||
await db.commit()
|
||||
|
||||
In neuem Issue referenzieren
Einen Benutzer sperren