diff --git a/src/modules/project-center/gitea.service.ts b/src/modules/project-center/gitea.service.ts index 8487bcf..8e67ce2 100644 --- a/src/modules/project-center/gitea.service.ts +++ b/src/modules/project-center/gitea.service.ts @@ -21,21 +21,25 @@ export class GiteaService { } async getRepos() { - const repos = await this.giteaGet('/repos/search?limit=50'); + // Try search with wildcard first, fall back to user repos + let repos = await this.giteaGet('/repos/search?q=&limit=50'); + if (!repos || repos.length === 0) { + repos = await this.giteaGet('/user/repos?limit=50'); + } if (!repos) return []; - return Promise.all(repos.map(async (r: any) => { - const [issues, pulls, milestones] = await Promise.all([ - this.giteaGet(`/repos/${r.full_name}/issues?state=all&limit=1`).then(d => d?.length ?? 0).catch(() => 0), - this.giteaGet(`/repos/${r.full_name}/pulls?state=all&limit=1`).then(d => d?.length ?? 0).catch(() => 0), - this.giteaGet(`/repos/${r.full_name}/milestones?state=open`).catch(() => []), - ]); - return { - id: r.id, name: r.name, fullName: r.full_name, description: r.description, - owner: r.owner?.login, stars: r.stars_count, forks: r.forks_count, - openIssues: r.open_issues_count, openPulls: pulls, milestones: milestones?.length ?? 0, + + const enriched: any[] = []; + for (const r of repos) { + const fullName = r.full_name; + // Just use open_issues_count from the search result; skip extra API calls + enriched.push({ + id: r.id, name: r.name, fullName, description: r.description, + owner: r.owner?.login, stars: r.stars_count ?? 0, forks: r.forks_count ?? 0, + openIssues: r.open_issues_count ?? 0, openPulls: 0, milestones: 0, defaultBranch: r.default_branch, updatedAt: r.updated_at, - }; - })); + }); + } + return enriched; } async getMilestones(owner: string, repo: string) {