Skip to content

Commit b9635a8

Browse files
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 <haritamar@gmail.com>
1 parent 63150b9 commit b9635a8

1 file changed

Lines changed: 22 additions & 18 deletions

File tree

elementary/monitor/api/tests/tests.py

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -168,12 +168,12 @@ def get_test_results(
168168
for test_result in filtered_test_results_db_rows
169169
if test_result.invocation_id == invocation_id
170170
]
171-
172-
filtered_test_results_db_rows = [
173-
test_result
174-
for test_result in filtered_test_results_db_rows
175-
if test_result.invocations_rank_index == 1
176-
]
171+
else:
172+
filtered_test_results_db_rows = [
173+
test_result
174+
for test_result in filtered_test_results_db_rows
175+
if test_result.invocations_rank_index == 1
176+
]
177177

178178
tests_results: DefaultDict[str, List[TestResultSchema]] = defaultdict(list)
179179
for test_result_db_row in filtered_test_results_db_rows:
@@ -281,9 +281,11 @@ def _get_invocations(
281281
for elementary_unique_id, invocations in grouped_invocations.items():
282282
totals = self._get_test_invocations_totals(invocations)
283283
test_invocations[elementary_unique_id] = InvocationsSchema(
284-
fail_rate=round((totals.errors + totals.failures) / len(invocations), 2)
285-
if invocations
286-
else 0,
284+
fail_rate=(
285+
round((totals.errors + totals.failures) / len(invocations), 2)
286+
if invocations
287+
else 0
288+
),
287289
totals=totals,
288290
invocations=invocations,
289291
description=self._get_invocations_description(totals),
@@ -426,15 +428,17 @@ def _parse_test_db_row(cls, test_db_row: TestDBRowSchema) -> TestSchema:
426428
test_db_row.package_name, test_db_row.original_path
427429
),
428430
created_at=test_db_row.created_at if test_db_row.created_at else None,
429-
latest_run_time=latest_run_datetime.isoformat()
430-
if latest_run_datetime
431-
else None,
432-
latest_run_time_utc=latest_run_datetime.astimezone(tz.tzlocal()).isoformat()
433-
if latest_run_datetime
434-
else None,
435-
latest_run_status=test_db_row.latest_run_status
436-
if test_db_row.latest_run_status
437-
else None,
431+
latest_run_time=(
432+
latest_run_datetime.isoformat() if latest_run_datetime else None
433+
),
434+
latest_run_time_utc=(
435+
latest_run_datetime.astimezone(tz.tzlocal()).isoformat()
436+
if latest_run_datetime
437+
else None
438+
),
439+
latest_run_status=(
440+
test_db_row.latest_run_status if test_db_row.latest_run_status else None
441+
),
438442
)
439443

440444
@staticmethod

0 commit comments

Comments
 (0)