From edef4c7cee3fc239798a44576441e9fed901e1ce Mon Sep 17 00:00:00 2001 From: Test User Date: Mon, 22 Dec 2025 13:13:47 -0500 Subject: [PATCH] refactor: optimize issue and PR fetching by using parallel execution - Updated the list-issues and list-prs handlers to fetch open and closed issues, as well as open and merged PRs in parallel, improving performance. - Removed the redundant 'issues' and 'prs' properties from the result interfaces to streamline the response structure. - Added 'skipTests' flag in integration tests to indicate tests that should be skipped, enhancing test management. --- .../src/routes/github/routes/list-issues.ts | 37 ++++++++++--------- .../src/routes/github/routes/list-prs.ts | 37 +++++++++---------- .../auto-mode-service.integration.test.ts | 6 +++ 3 files changed, 43 insertions(+), 37 deletions(-) diff --git a/apps/server/src/routes/github/routes/list-issues.ts b/apps/server/src/routes/github/routes/list-issues.ts index 49850242..08f94135 100644 --- a/apps/server/src/routes/github/routes/list-issues.ts +++ b/apps/server/src/routes/github/routes/list-issues.ts @@ -28,7 +28,6 @@ export interface GitHubIssue { export interface ListIssuesResult { success: boolean; - issues?: GitHubIssue[]; openIssues?: GitHubIssue[]; closedIssues?: GitHubIssue[]; error?: string; @@ -54,23 +53,26 @@ export function createListIssuesHandler() { return; } - // Fetch open issues - const { stdout: openStdout } = await execAsync( - 'gh issue list --state open --json number,title,state,author,createdAt,labels,url,body --limit 100', - { - cwd: projectPath, - env: execEnv, - } - ); + // Fetch open and closed issues in parallel + const [openResult, closedResult] = await Promise.all([ + execAsync( + 'gh issue list --state open --json number,title,state,author,createdAt,labels,url,body --limit 100', + { + cwd: projectPath, + env: execEnv, + } + ), + execAsync( + 'gh issue list --state closed --json number,title,state,author,createdAt,labels,url,body --limit 50', + { + cwd: projectPath, + env: execEnv, + } + ), + ]); - // Fetch closed issues - const { stdout: closedStdout } = await execAsync( - 'gh issue list --state closed --json number,title,state,author,createdAt,labels,url,body --limit 50', - { - cwd: projectPath, - env: execEnv, - } - ); + const { stdout: openStdout } = openResult; + const { stdout: closedStdout } = closedResult; const openIssues: GitHubIssue[] = JSON.parse(openStdout || '[]'); const closedIssues: GitHubIssue[] = JSON.parse(closedStdout || '[]'); @@ -79,7 +81,6 @@ export function createListIssuesHandler() { success: true, openIssues, closedIssues, - issues: [...openIssues, ...closedIssues], }); } catch (error) { logError(error, 'List GitHub issues failed'); diff --git a/apps/server/src/routes/github/routes/list-prs.ts b/apps/server/src/routes/github/routes/list-prs.ts index 2dd0b2c4..87f42a38 100644 --- a/apps/server/src/routes/github/routes/list-prs.ts +++ b/apps/server/src/routes/github/routes/list-prs.ts @@ -32,7 +32,6 @@ export interface GitHubPR { export interface ListPRsResult { success: boolean; - prs?: GitHubPR[]; openPRs?: GitHubPR[]; mergedPRs?: GitHubPR[]; error?: string; @@ -58,23 +57,24 @@ export function createListPRsHandler() { return; } - // Fetch open PRs - const { stdout: openStdout } = await execAsync( - 'gh pr list --state open --json number,title,state,author,createdAt,labels,url,isDraft,headRefName,reviewDecision,mergeable,body --limit 100', - { - cwd: projectPath, - env: execEnv, - } - ); - - // Fetch merged PRs - const { stdout: mergedStdout } = await execAsync( - 'gh pr list --state merged --json number,title,state,author,createdAt,labels,url,isDraft,headRefName,reviewDecision,mergeable,body --limit 50', - { - cwd: projectPath, - env: execEnv, - } - ); + const [openResult, mergedResult] = await Promise.all([ + execAsync( + 'gh pr list --state open --json number,title,state,author,createdAt,labels,url,isDraft,headRefName,reviewDecision,mergeable,body --limit 100', + { + cwd: projectPath, + env: execEnv, + } + ), + execAsync( + 'gh pr list --state merged --json number,title,state,author,createdAt,labels,url,isDraft,headRefName,reviewDecision,mergeable,body --limit 50', + { + cwd: projectPath, + env: execEnv, + } + ), + ]); + const { stdout: openStdout } = openResult; + const { stdout: mergedStdout } = mergedResult; const openPRs: GitHubPR[] = JSON.parse(openStdout || '[]'); const mergedPRs: GitHubPR[] = JSON.parse(mergedStdout || '[]'); @@ -83,7 +83,6 @@ export function createListPRsHandler() { success: true, openPRs, mergedPRs, - prs: [...openPRs, ...mergedPRs], }); } catch (error) { logError(error, 'List GitHub PRs failed'); diff --git a/apps/server/tests/integration/services/auto-mode-service.integration.test.ts b/apps/server/tests/integration/services/auto-mode-service.integration.test.ts index d9d6ee13..e0ab4c4d 100644 --- a/apps/server/tests/integration/services/auto-mode-service.integration.test.ts +++ b/apps/server/tests/integration/services/auto-mode-service.integration.test.ts @@ -146,6 +146,7 @@ describe('auto-mode-service.ts (integration)', () => { category: 'test', description: 'Test without worktree', status: 'pending', + skipTests: true, }); const mockProvider = { @@ -181,6 +182,7 @@ describe('auto-mode-service.ts (integration)', () => { category: 'ui', description: 'Execute this feature', status: 'pending', + skipTests: true, }); const mockProvider = { @@ -327,6 +329,7 @@ describe('auto-mode-service.ts (integration)', () => { category: 'test', description: 'Auto feature 1', status: 'pending', + skipTests: true, }); await createTestFeature(testRepo.path, 'auto-2', { @@ -334,6 +337,7 @@ describe('auto-mode-service.ts (integration)', () => { category: 'test', description: 'Auto feature 2', status: 'pending', + skipTests: true, }); const mockProvider = { @@ -520,6 +524,7 @@ describe('auto-mode-service.ts (integration)', () => { description: 'Feature with skip planning', status: 'pending', planningMode: 'skip', + skipTests: true, }); const mockProvider = { @@ -555,6 +560,7 @@ describe('auto-mode-service.ts (integration)', () => { status: 'pending', planningMode: 'lite', requirePlanApproval: false, + skipTests: true, }); const mockProvider = {