From b9635a80e54d2748918a38317a5d364e5f4c992a Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Thu, 12 Mar 2026 15:38:35 +0000 Subject: [PATCH] fix: only filter by invocations_rank_index when no invocation_id is specified When using 'edr report --select invocation_id:XXXX', the report showed 0 tests for non-latest invocations because the invocations_rank_index == 1 filter ran unconditionally after the invocation_id filter, removing all results where the selected invocation wasn't the most recent one. This mirrors the existing correct pattern in get_test_results_summary(). Co-Authored-By: Itamar Hartstein --- elementary/monitor/api/tests/tests.py | 40 +++++++++++++++------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/elementary/monitor/api/tests/tests.py b/elementary/monitor/api/tests/tests.py index 4d603a4ea..7a252b0a1 100644 --- a/elementary/monitor/api/tests/tests.py +++ b/elementary/monitor/api/tests/tests.py @@ -168,12 +168,12 @@ def get_test_results( for test_result in filtered_test_results_db_rows if test_result.invocation_id == invocation_id ] - - filtered_test_results_db_rows = [ - test_result - for test_result in filtered_test_results_db_rows - if test_result.invocations_rank_index == 1 - ] + else: + filtered_test_results_db_rows = [ + test_result + for test_result in filtered_test_results_db_rows + if test_result.invocations_rank_index == 1 + ] tests_results: DefaultDict[str, List[TestResultSchema]] = defaultdict(list) for test_result_db_row in filtered_test_results_db_rows: @@ -281,9 +281,11 @@ def _get_invocations( for elementary_unique_id, invocations in grouped_invocations.items(): totals = self._get_test_invocations_totals(invocations) test_invocations[elementary_unique_id] = InvocationsSchema( - fail_rate=round((totals.errors + totals.failures) / len(invocations), 2) - if invocations - else 0, + fail_rate=( + round((totals.errors + totals.failures) / len(invocations), 2) + if invocations + else 0 + ), totals=totals, invocations=invocations, description=self._get_invocations_description(totals), @@ -426,15 +428,17 @@ def _parse_test_db_row(cls, test_db_row: TestDBRowSchema) -> TestSchema: test_db_row.package_name, test_db_row.original_path ), created_at=test_db_row.created_at if test_db_row.created_at else None, - latest_run_time=latest_run_datetime.isoformat() - if latest_run_datetime - else None, - latest_run_time_utc=latest_run_datetime.astimezone(tz.tzlocal()).isoformat() - if latest_run_datetime - else None, - latest_run_status=test_db_row.latest_run_status - if test_db_row.latest_run_status - else None, + latest_run_time=( + latest_run_datetime.isoformat() if latest_run_datetime else None + ), + latest_run_time_utc=( + latest_run_datetime.astimezone(tz.tzlocal()).isoformat() + if latest_run_datetime + else None + ), + latest_run_status=( + test_db_row.latest_run_status if test_db_row.latest_run_status else None + ), ) @staticmethod