(issueNumber: number)
| 185 | |
| 186 | // 获取单个 issue 详情 |
| 187 | static async getIssue(issueNumber: number): Promise<{ |
| 188 | title: string; |
| 189 | body: string; |
| 190 | created_at: string; |
| 191 | user: { login: string; avatar_url: string }; |
| 192 | comments: number; |
| 193 | reactions: { total_count: number }; |
| 194 | image?: string; |
| 195 | category?: string; |
| 196 | }> { |
| 197 | const cacheKey = `issue_${issueNumber}`; |
| 198 | const cached = cache.get<{ |
| 199 | title: string; |
| 200 | body: string; |
| 201 | created_at: string; |
| 202 | user: { login: string; avatar_url: string }; |
| 203 | comments: number; |
| 204 | reactions: { total_count: number }; |
| 205 | image?: string; |
| 206 | category?: string; |
| 207 | }>(cacheKey); |
| 208 | |
| 209 | if (cached) { |
| 210 | console.log('Using cached issue data for:', issueNumber); |
| 211 | return cached; |
| 212 | } |
| 213 | |
| 214 | try { |
| 215 | const url = `${this.BASE_URL}/repos/${this.REPO_OWNER}/${this.REPO_NAME}/issues/${issueNumber}`; |
| 216 | console.log('Fetching issue from:', url); |
| 217 | |
| 218 | const response = await this.fetchWithRetry(url, { |
| 219 | headers: this.getHeaders() |
| 220 | }); |
| 221 | |
| 222 | if (!response.ok) { |
| 223 | console.error(`GitHub API error: ${response.status} - ${response.statusText}`); |
| 224 | if (response.status === 403) { |
| 225 | console.error('GitHub API rate limit exceeded'); |
| 226 | throw new Error('GitHub API rate limit exceeded'); |
| 227 | } |
| 228 | throw new Error(`GitHub API error: ${response.status}`); |
| 229 | } |
| 230 | |
| 231 | const issue: GitHubIssue = await response.json(); |
| 232 | console.log('Fetched issue data:', { |
| 233 | number: issue.number, |
| 234 | title: issue.title, |
| 235 | bodyLength: issue.body?.length || 0 |
| 236 | }); |
| 237 | |
| 238 | const image = this.extractImageFromBody(issue.body); |
| 239 | const category = this.extractCategoryFromBody(issue.body); |
| 240 | |
| 241 | const result = { |
| 242 | title: issue.title, |
| 243 | body: issue.body || '', |
| 244 | created_at: issue.created_at, |
no test coverage detected