Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions apiserver/dora/service/code/sync/etl_github_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,11 +319,12 @@ def _to_pr_commits(

{
'sha': '123456789098765',
'commit': {'author': {'name': 'abc', 'email': 'abc@midd.com', 'date': '2022-06-29T10:53:15Z'},
'committer': {'name': 'abc', 'email': 'abc@midd.com', 'date': '2022-06-29T10:53:15Z'},
'message': '[abc 315] avoid mapping edit state',
'html_url': 'https://github.com/abc',
'author': {'login': 'abc', 'id': 95607047, 'node_id': 'abc', 'avatar_url': ''},
'commit': {
'author': {'name': 'abc', 'email': 'abc@midd.com', 'date': '2022-06-29T10:53:15Z'},
'committer': {'name': 'abc', 'email': 'abc@midd.com', 'date': '2022-06-29T10:53:15Z'},
'message': '[abc 315] avoid mapping edit state',
'html_url': 'https://github.com/abc',
'author': {'login': 'abc', 'id': 95607047, 'node_id': 'abc', 'avatar_url': ''},
}
"""
pr_commits: List[PullRequestCommit] = []
Expand All @@ -349,9 +350,8 @@ def _to_pr_commits(

@staticmethod
def _dt_from_github_dt_string(dt_string: str) -> datetime:
return datetime.strptime(dt_string, "%Y-%m-%dT%H:%M:%SZ").astimezone(
tz=pytz.UTC
)
dt_without_timezone = datetime.strptime(dt_string, "%Y-%m-%dT%H:%M:%SZ")
return dt_without_timezone.replace(tzinfo=pytz.UTC)


def get_github_etl_handler(org_id: str) -> GithubETLHandler:
Expand Down
14 changes: 14 additions & 0 deletions apiserver/tests/service/code/sync/test_etl_github_handler.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from datetime import datetime

import pytz

from dora.service.code.sync.etl_github_handler import GithubETLHandler
from dora.utils.string import uuid4_str

ORG_ID = uuid4_str()


def test__dt_from_github_dt_string_given_date_string_returns_correct_datetime():
date_string = "2024-04-18T10:53:15Z"
expected = datetime(2024, 4, 18, 10, 53, 15, tzinfo=pytz.UTC)
assert GithubETLHandler._dt_from_github_dt_string(date_string) == expected