Skip to content

Commit 5cf8fad

Browse files
fix: swap latest_run_time and latest_run_time_utc in _parse_test_db_row
In _parse_test_db_row, latest_run_time was set to the raw UTC datetime and latest_run_time_utc was converted to local time, which is backwards. This swaps them to match the correct pattern in _get_test_metadata_from_test_result_db_row where latest_run_time is local time and latest_run_time_utc is UTC. Co-Authored-By: Itamar Hartstein <[email protected]>
1 parent 63150b9 commit 5cf8fad

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

elementary/monitor/api/tests/tests.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -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.astimezone(tz.tzlocal()).isoformat()
433+
if latest_run_datetime
434+
else None
435+
),
436+
latest_run_time_utc=(
437+
latest_run_datetime.isoformat() if latest_run_datetime 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)