diff --git a/src/ai/backend/client/utils.py b/src/ai/backend/client/utils.py index c408b670823..da5dca43521 100644 --- a/src/ai/backend/client/utils.py +++ b/src/ai/backend/client/utils.py @@ -57,7 +57,7 @@ def get_lastest_timestamp_for_status( status_history: list[dict[str, str]], status: str, ) -> Optional[datetime]: - for item in status_history: + for item in reversed(status_history): if item["status"] == status: return dtparse(item["timestamp"]) return None diff --git a/src/ai/backend/manager/models/utils.py b/src/ai/backend/manager/models/utils.py index e855c99e316..bc108fd7af5 100644 --- a/src/ai/backend/manager/models/utils.py +++ b/src/ai/backend/manager/models/utils.py @@ -573,7 +573,7 @@ def get_lastest_timestamp_for_status( If the status is not found, return None. """ - for item in list(reversed(status_history_log)): + for item in reversed(status_history_log): if item["status"] == status: return dtparse(item["timestamp"]) return None