Skip to content

fix: swap latest_run_time and latest_run_time_utc in _parse_test_db_row#2144

Merged
haritamar merged 1 commit intomasterfrom
devin/1773330400-fix-swapped-timestamps
Mar 12, 2026
Merged

fix: swap latest_run_time and latest_run_time_utc in _parse_test_db_row#2144
haritamar merged 1 commit intomasterfrom
devin/1773330400-fix-swapped-timestamps

Conversation

@devin-ai-integration
Copy link
Contributor

@devin-ai-integration devin-ai-integration bot commented Mar 12, 2026

fix: swap latest_run_time and latest_run_time_utc in _parse_test_db_row

Summary

In _parse_test_db_row, the latest_run_time and latest_run_time_utc fields were assigned backwards:

  • latest_run_time was set to the raw UTC datetime (.isoformat())
  • latest_run_time_utc was set to local time (.astimezone(tz.tzlocal()).isoformat())

This swaps them to match the correct pattern already used in _get_test_metadata_from_test_result_db_row, where latest_run_time is local time and latest_run_time_utc is UTC.

The remaining diff lines are cosmetic black reformatting (no logic changes).

Originally spotted by CodeRabbit on PR #2143.

Review & Testing Checklist for Human

  • Verify no downstream consumers of TestSchema.latest_run_time or TestSchema.latest_run_time_utc were accidentally relying on the old (incorrect) values — i.e., compensating for the bug elsewhere. Search for usages of these fields across the codebase and the frontend report.
  • Test edr report and confirm timestamps display correctly (local time where expected, UTC where expected)

Notes

Summary by CodeRabbit

  • Style
    • Code formatting improvements for enhanced readability.

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 <haritamar@gmail.com>
@devin-ai-integration
Copy link
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@github-actions
Copy link
Contributor

👋 @devin-ai-integration[bot]
Thank you for raising your pull request.
Please make sure to add tests and document all user-facing changes.
You can do this by editing the docs files in this pull request.

@coderabbitai
Copy link

coderabbitai bot commented Mar 12, 2026

📝 Walkthrough

Walkthrough

Minor formatting improvements in test API helper functions—parentheses added to fail_rate calculation and multi-line assignments for timestamp and status fields. No functional logic changes.

Changes

Cohort / File(s) Summary
Formatting Refactor
elementary/monitor/api/tests/tests.py
Parentheses wrapping added to _get_invocations fail_rate calculation and _parse_test_db_row latest_run_time/status assignments for improved readability across multiple lines.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 With whiskers twitching, I hop with glee,
Parentheses dancing in harmony,
Lines now formatted, oh so neat,
No logic changed—just style so sweet!
—The Code Rabbit 🐇

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main bug fix: swapping two incorrectly assigned timestamp variables in the _parse_test_db_row function.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch devin/1773330400-fix-swapped-timestamps
📝 Coding Plan for PR comments
  • Generate coding plan

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
elementary/monitor/api/tests/tests.py (1)

431-441: Add a regression test for the timestamp field mapping in _parse_test_db_row.

The code change is correct—latest_run_time now properly converts to local time and latest_run_time_utc stays in UTC. However, this bug silently affects serialized API output. A focused test assertion on these two fields would prevent accidental regression. The mock data in tests_fetcher_mock.py already provides latest_run_time values; extend test_parse_test_db_row to assert that the returned TestSchema correctly separates local vs. UTC timestamps.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@elementary/monitor/api/tests/tests.py` around lines 431 - 441, Add a
regression assertion in the test_parse_test_db_row unit test to verify
_parse_test_db_row maps timestamps correctly: assert that the returned
TestSchema.latest_run_time is the local-time ISO string (converted via
astimezone(tz.tzlocal())) and TestSchema.latest_run_time_utc is the original UTC
ISO string; use the mock latest_run_time values from tests_fetcher_mock.py to
construct expected strings and compare them to the parsed result to prevent
future regressions.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@elementary/monitor/api/tests/tests.py`:
- Around line 431-441: Add a regression assertion in the test_parse_test_db_row
unit test to verify _parse_test_db_row maps timestamps correctly: assert that
the returned TestSchema.latest_run_time is the local-time ISO string (converted
via astimezone(tz.tzlocal())) and TestSchema.latest_run_time_utc is the original
UTC ISO string; use the mock latest_run_time values from tests_fetcher_mock.py
to construct expected strings and compare them to the parsed result to prevent
future regressions.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 640296eb-4837-4f6d-905c-a3c4663ed842

📥 Commits

Reviewing files that changed from the base of the PR and between 63150b9 and 5cf8fad.

📒 Files selected for processing (1)
  • elementary/monitor/api/tests/tests.py

@haritamar haritamar merged commit 035653a into master Mar 12, 2026
25 checks passed
@haritamar haritamar deleted the devin/1773330400-fix-swapped-timestamps branch March 12, 2026 16:03
devin-ai-integration bot added a commit that referenced this pull request Mar 12, 2026
Co-Authored-By: Itamar Hartstein <haritamar@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant