Skip to content

Fix timezone-aware vs naive datetime comparison in correlate_git_with_sessions #34

Description

@evansenter

Problem

The correlate_git_with_sessions() function in queries.py throws a TypeError when comparing timezone-aware and naive datetime objects. This happens when git commits have timezone information but session timestamps don't (or vice versa).

Current Workaround

Tests skip this case with pytest.skip():

try:
    result = correlate_git_with_sessions.fn(days=7)
except TypeError:
    pytest.skip("Timezone comparison issue in correlate_git_with_sessions")

Expected Behavior

The function should handle both timezone-aware and naive datetimes gracefully, either by:

  1. Normalizing all datetimes to UTC
  2. Stripping timezone info for comparison
  3. Making all timestamps timezone-aware

Files Affected

  • src/session_analytics/queries.py - correlate_git_with_sessions() function
  • tests/test_server.py:225-238 - test with skip workaround
  • tests/test_cli.py:626-630 - CLI test with skip workaround

Context

Discovered during test audit in PR #32.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions