diff --git a/RELEASE_NOTES_v2.2.44.md b/RELEASE_NOTES_v2.2.44.md new file mode 100644 index 0000000..d4836d8 --- /dev/null +++ b/RELEASE_NOTES_v2.2.44.md @@ -0,0 +1,17 @@ +# Release Notes v2.2.44 + +Dato: 4. marts 2026 + +## Fixes +- `updateto.sh` rydder nu automatisk legacy containere (`bmc-hub-api-v2`, `bmc-hub-postgres-v2`) før deploy. +- Forebygger port-lock konflikter på især Postgres host-port (`5433`) under compose opstart. +- Mission Control: automatisk timeout på hængende `ringing` opkald, så de ikke bliver stående i Incoming Calls. + +## Ændrede filer +- `updateto.sh` +- `app/dashboard/backend/mission_service.py` +- `VERSION` + +## Drift +- Deploy: `./updateto.sh v2.2.44` +- Verificér: `curl http://localhost:8001/health` diff --git a/VERSION b/VERSION index e3a4d65..b11160b 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.2.43 +2.2.44 diff --git a/app/dashboard/backend/mission_service.py b/app/dashboard/backend/mission_service.py index 53b0ef1..19ca54d 100644 --- a/app/dashboard/backend/mission_service.py +++ b/app/dashboard/backend/mission_service.py @@ -5,6 +5,30 @@ from app.core.database import execute_query, execute_query_single class MissionService: + @staticmethod + def get_ring_timeout_seconds() -> int: + raw = MissionService.get_setting_value("mission_call_ring_timeout_seconds", "180") or "180" + try: + value = int(raw) + except (TypeError, ValueError): + value = 180 + return max(30, min(value, 3600)) + + @staticmethod + def expire_stale_ringing_calls() -> None: + timeout_seconds = MissionService.get_ring_timeout_seconds() + execute_query( + """ + UPDATE mission_call_state + SET state = 'hangup', + ended_at = COALESCE(ended_at, NOW()), + updated_at = NOW() + WHERE state = 'ringing' + AND started_at < (NOW() - make_interval(secs => %s)) + """, + (timeout_seconds,), + ) + @staticmethod def get_setting_value(key: str, default: Optional[str] = None) -> Optional[str]: row = execute_query_single("SELECT value FROM settings WHERE key = %s", (key,)) @@ -144,6 +168,7 @@ class MissionService: @staticmethod def get_active_calls() -> list[Dict[str, Any]]: + MissionService.expire_stale_ringing_calls() rows = execute_query( """ SELECT call_id, queue_name, caller_number, contact_name, company_name, customer_tag, state, started_at, answered_at, ended_at, updated_at diff --git a/updateto.sh b/updateto.sh index b0d954e..be3d55d 100644 --- a/updateto.sh +++ b/updateto.sh @@ -74,6 +74,13 @@ fi echo "✅ .env opdateret" +# Cleanup legacy container names from older compose variants (can lock host ports) +echo "" +echo "🧹 Rydder legacy containere (v2-navne)..." +podman update --restart=no bmc-hub-api-v2 bmc-hub-postgres-v2 >/dev/null 2>&1 || true +podman stop bmc-hub-api-v2 bmc-hub-postgres-v2 >/dev/null 2>&1 || true +podman rm -f bmc-hub-api-v2 bmc-hub-postgres-v2 >/dev/null 2>&1 || true + # Guard against host port conflicts before attempting startup POSTGRES_BIND_ADDR="${POSTGRES_BIND_ADDR:-127.0.0.1}" POSTGRES_PORT="${POSTGRES_PORT:-5432}"