-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgithub_client.py
More file actions
38 lines (32 loc) · 1.15 KB
/
github_client.py
File metadata and controls
38 lines (32 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import os
from github import Github
from models import GitHubIssue
from typing import List
from dotenv import load_dotenv
load_dotenv()
class GitHubClient:
def __init__(self):
token = os.getenv("GITHUB_TOKEN")
if not token:
raise ValueError("GITHUB_TOKEN not found in environment variables")
self.gh = Github(token)
def fetch_recent_issues(self, repo_full_name: str, limit: int = 10) -> List[GitHubIssue]:
repo = self.gh.get_repo(repo_full_name)
issues = repo.get_issues(state='open', sort='created', direction='desc')
result = []
count = 0
for issue in issues:
if issue.pull_request: # Skip PRs
continue
result.append(GitHubIssue(
id=issue.id,
number=issue.number,
title=issue.title,
body=issue.body if issue.body else "",
html_url=issue.html_url,
repo_name=repo_full_name
))
count += 1
if count >= limit:
break
return result