From ad0b35c09fed6a5d92c526b56ce0f6190bced478 Mon Sep 17 00:00:00 2001 From: JiriUhlir <149317995+JiriUhlir@users.noreply.github.com> Date: Mon, 8 Jun 2026 07:53:21 +0200 Subject: [PATCH] =?UTF-8?q?Upraveno.=20Port=C3=A1l=20u=C5=BE=20neur=C4=8Du?= =?UTF-8?q?je=20readiness=20podle=20job.status=20=3D=3D=20success=20ani=20?= =?UTF-8?q?podle=20=C5=BE=C3=A1dn=C3=A9=20Docker/group=20logiky.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Teď READY / NOT READY bere jen z explicitního výstupu skriptu uloženého v DB: result_json.ready jako boolean, result_json.readiness / migration_readiness s hodnotou READY nebo NOT READY, případně text READY / NOT READY v uloženém raw výstupu jobu. --- app/db/migration_readiness.py | 42 ++++++++++++++++++++----------- app/routes/migration_readiness.py | 2 +- 2 files changed, 28 insertions(+), 16 deletions(-) diff --git a/app/db/migration_readiness.py b/app/db/migration_readiness.py index d0deff7..4a7e343 100644 --- a/app/db/migration_readiness.py +++ b/app/db/migration_readiness.py @@ -89,6 +89,32 @@ def _first_int(data: dict[str, Any], keys: tuple[str, ...]) -> int | None: return None +def _readiness_from_script_output(result_data: dict[str, Any], combined_text: str) -> bool: + ready_value = result_data.get("ready") + if isinstance(ready_value, bool): + return ready_value + + readiness_value = str( + result_data.get("readiness") + or result_data.get("migration_readiness") + or result_data.get("migrationReadiness") + or "" + ).strip().upper() + + if readiness_value == "READY": + return True + if readiness_value == "NOT READY": + return False + + upper_text = combined_text.upper() + if re.search(r"(? dict[str, Any]: if not job: return { @@ -123,22 +149,8 @@ def summarize_readiness(job: dict[str, Any] | None) -> dict[str, Any]: if fail_count is None: fail_count = _count_token(combined_text, "FAIL") - readiness_value = str( - result_data.get("readiness") - or result_data.get("ready") - or result_data.get("status") - or "" - ).strip().upper() - - if readiness_value in {"READY", "TRUE", "OK", "SUCCESS"}: - ready = fail_count == 0 and (job.get("status") or "").lower() == "success" - elif readiness_value in {"NOT READY", "FALSE", "FAIL", "FAILED", "ERROR"}: - ready = False - else: - ready = fail_count == 0 and (job.get("status") or "").lower() == "success" - return { - "ready": ready, + "ready": _readiness_from_script_output(result_data, combined_text), "ok_count": ok_count, "warn_count": warn_count, "fail_count": fail_count, diff --git a/app/routes/migration_readiness.py b/app/routes/migration_readiness.py index ee72f81..6aa7969 100644 --- a/app/routes/migration_readiness.py +++ b/app/routes/migration_readiness.py @@ -54,7 +54,7 @@ def migration_readiness_page(request: Request, user=Depends(require_user)): f"""

Migration Readiness

-

Poslední výsledek maintenance skriptu {html.escape(PREFLIGHT_SCRIPT)} uložený v databázi.

+

Poslední výsledek maintenance skriptu {html.escape(PREFLIGHT_SCRIPT)} uložený v databázi. Stav vychází pouze z výstupu skriptu.