diff --git a/app/core/api_handler.py b/app/core/api_handler.py index 4ee3b22..5151294 100644 --- a/app/core/api_handler.py +++ b/app/core/api_handler.py @@ -66,6 +66,8 @@ def extract_issue_data(raw_issue: tuple): issue['comments'] = raw_issue[1]['comments'] issue['labels'] = [l['name'] for l in raw_issue[1].get('labels', [])] issue['state'] = raw_issue[1].get('state', 'open') + issue['created_at'] = raw_issue[1].get('created_at', '') + issue['updated_at'] = raw_issue[1].get('updated_at', '') return issue except Exception as error: @@ -130,6 +132,8 @@ def render_template(csv_path, template_path, today): 'title': row['title'].replace('|', '\\|'), # Escape '|' to avoid breaking markdown table rows 'url': row['url'], 'comments': row['comments'], + 'created_at': row.get('created_at', ''), + 'updated_at': row.get('updated_at', ''), }) env = Environment(loader=FileSystemLoader(template_path)) @@ -163,6 +167,8 @@ def write_output(issues, output_file): 'comments', 'labels', 'state' + 'created_at', + 'updated_at', ] ) writer.writeheader() diff --git a/app/templates/README.md.j2 b/app/templates/README.md.j2 index 074bd7c..bfdcc17 100644 --- a/app/templates/README.md.j2 +++ b/app/templates/README.md.j2 @@ -64,8 +64,8 @@ If this repository helped you in your open source journey, consider giving it a ## Good First Issues Last run: {{today}} -| Repo | Language | Title | Comments | -|---|---|---|---| +| Repo | Language | Title | Comments | Created | Updated | +|---|---|---|---|---|---| {% for result in results -%} -| {{result.repo}} | {{result.language}} | [{{result.title}}]({{result.url}}) | {{result.comments}} | +| {{result.repo}} | {{result.language}} | [{{result.title}}]({{result.url}}) | {{result.comments}} | {{result.created_at}} | {{result.updated_at}} | {% endfor %} diff --git a/app/tests/test_api_handler.py b/app/tests/test_api_handler.py index 2ed9bef..081a214 100644 --- a/app/tests/test_api_handler.py +++ b/app/tests/test_api_handler.py @@ -83,25 +83,33 @@ def test_extract_repos_error(self, mock_extract_number, mock_api_client): class TestIssueManager: @patch('app.core.api_handler.APIClient') def test_extract_issue_data(self, mock_api_client): - raw_issue = ( - "Python", - { - "repository_url": "https://api.github.com/repos/owner/repo", - "title": "Test Issue", - "html_url": "https://github.com/owner/repo/issues/1", - "comments": 5 - } - ) - - result = IssueManager().extract_issue_data(raw_issue) - - assert result == { - "repo": "owner/repo", - "language": "Python", - "title": "Test Issue", - "url": "https://github.com/owner/repo/issues/1", - "comments": 5 - } + raw_issue = ( + "Python", + { + "repository_url": "https://api.github.com/repos/owner/repo", + "title": "Test Issue", + "html_url": "https://github.com/owner/repo/issues/1", + "comments": 5, + "labels": [], + "state": "open", + "created_at": "2024-01-15T10:00:00Z", + "updated_at": "2024-02-20T12:00:00Z", + } +) + +result = IssueManager().extract_issue_data(raw_issue) + +assert result == { + "repo": "owner/repo", + "language": "Python", + "title": "Test Issue", + "url": "https://github.com/owner/repo/issues/1", + "comments": 5, + "labels": [], + "state": "open", + "created_at": "2024-01-15T10:00:00Z", + "updated_at": "2024-02-20T12:00:00Z", +} @patch('app.core.api_handler.APIClient') def test_extract_language(self, mock_api_client):