Skip to content

Commit edef4c7

Browse files
author
Test User
committed
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.
1 parent 0c508ce commit edef4c7

3 files changed

Lines changed: 43 additions & 37 deletions

File tree

apps/server/src/routes/github/routes/list-issues.ts

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ export interface GitHubIssue {
2828

2929
export interface ListIssuesResult {
3030
success: boolean;
31-
issues?: GitHubIssue[];
3231
openIssues?: GitHubIssue[];
3332
closedIssues?: GitHubIssue[];
3433
error?: string;
@@ -54,23 +53,26 @@ export function createListIssuesHandler() {
5453
return;
5554
}
5655

57-
// Fetch open issues
58-
const { stdout: openStdout } = await execAsync(
59-
'gh issue list --state open --json number,title,state,author,createdAt,labels,url,body --limit 100',
60-
{
61-
cwd: projectPath,
62-
env: execEnv,
63-
}
64-
);
56+
// Fetch open and closed issues in parallel
57+
const [openResult, closedResult] = await Promise.all([
58+
execAsync(
59+
'gh issue list --state open --json number,title,state,author,createdAt,labels,url,body --limit 100',
60+
{
61+
cwd: projectPath,
62+
env: execEnv,
63+
}
64+
),
65+
execAsync(
66+
'gh issue list --state closed --json number,title,state,author,createdAt,labels,url,body --limit 50',
67+
{
68+
cwd: projectPath,
69+
env: execEnv,
70+
}
71+
),
72+
]);
6573

66-
// Fetch closed issues
67-
const { stdout: closedStdout } = await execAsync(
68-
'gh issue list --state closed --json number,title,state,author,createdAt,labels,url,body --limit 50',
69-
{
70-
cwd: projectPath,
71-
env: execEnv,
72-
}
73-
);
74+
const { stdout: openStdout } = openResult;
75+
const { stdout: closedStdout } = closedResult;
7476

7577
const openIssues: GitHubIssue[] = JSON.parse(openStdout || '[]');
7678
const closedIssues: GitHubIssue[] = JSON.parse(closedStdout || '[]');
@@ -79,7 +81,6 @@ export function createListIssuesHandler() {
7981
success: true,
8082
openIssues,
8183
closedIssues,
82-
issues: [...openIssues, ...closedIssues],
8384
});
8485
} catch (error) {
8586
logError(error, 'List GitHub issues failed');

apps/server/src/routes/github/routes/list-prs.ts

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ export interface GitHubPR {
3232

3333
export interface ListPRsResult {
3434
success: boolean;
35-
prs?: GitHubPR[];
3635
openPRs?: GitHubPR[];
3736
mergedPRs?: GitHubPR[];
3837
error?: string;
@@ -58,23 +57,24 @@ export function createListPRsHandler() {
5857
return;
5958
}
6059

61-
// Fetch open PRs
62-
const { stdout: openStdout } = await execAsync(
63-
'gh pr list --state open --json number,title,state,author,createdAt,labels,url,isDraft,headRefName,reviewDecision,mergeable,body --limit 100',
64-
{
65-
cwd: projectPath,
66-
env: execEnv,
67-
}
68-
);
69-
70-
// Fetch merged PRs
71-
const { stdout: mergedStdout } = await execAsync(
72-
'gh pr list --state merged --json number,title,state,author,createdAt,labels,url,isDraft,headRefName,reviewDecision,mergeable,body --limit 50',
73-
{
74-
cwd: projectPath,
75-
env: execEnv,
76-
}
77-
);
60+
const [openResult, mergedResult] = await Promise.all([
61+
execAsync(
62+
'gh pr list --state open --json number,title,state,author,createdAt,labels,url,isDraft,headRefName,reviewDecision,mergeable,body --limit 100',
63+
{
64+
cwd: projectPath,
65+
env: execEnv,
66+
}
67+
),
68+
execAsync(
69+
'gh pr list --state merged --json number,title,state,author,createdAt,labels,url,isDraft,headRefName,reviewDecision,mergeable,body --limit 50',
70+
{
71+
cwd: projectPath,
72+
env: execEnv,
73+
}
74+
),
75+
]);
76+
const { stdout: openStdout } = openResult;
77+
const { stdout: mergedStdout } = mergedResult;
7878

7979
const openPRs: GitHubPR[] = JSON.parse(openStdout || '[]');
8080
const mergedPRs: GitHubPR[] = JSON.parse(mergedStdout || '[]');
@@ -83,7 +83,6 @@ export function createListPRsHandler() {
8383
success: true,
8484
openPRs,
8585
mergedPRs,
86-
prs: [...openPRs, ...mergedPRs],
8786
});
8887
} catch (error) {
8988
logError(error, 'List GitHub PRs failed');

apps/server/tests/integration/services/auto-mode-service.integration.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ describe('auto-mode-service.ts (integration)', () => {
146146
category: 'test',
147147
description: 'Test without worktree',
148148
status: 'pending',
149+
skipTests: true,
149150
});
150151

151152
const mockProvider = {
@@ -181,6 +182,7 @@ describe('auto-mode-service.ts (integration)', () => {
181182
category: 'ui',
182183
description: 'Execute this feature',
183184
status: 'pending',
185+
skipTests: true,
184186
});
185187

186188
const mockProvider = {
@@ -327,13 +329,15 @@ describe('auto-mode-service.ts (integration)', () => {
327329
category: 'test',
328330
description: 'Auto feature 1',
329331
status: 'pending',
332+
skipTests: true,
330333
});
331334

332335
await createTestFeature(testRepo.path, 'auto-2', {
333336
id: 'auto-2',
334337
category: 'test',
335338
description: 'Auto feature 2',
336339
status: 'pending',
340+
skipTests: true,
337341
});
338342

339343
const mockProvider = {
@@ -520,6 +524,7 @@ describe('auto-mode-service.ts (integration)', () => {
520524
description: 'Feature with skip planning',
521525
status: 'pending',
522526
planningMode: 'skip',
527+
skipTests: true,
523528
});
524529

525530
const mockProvider = {
@@ -555,6 +560,7 @@ describe('auto-mode-service.ts (integration)', () => {
555560
status: 'pending',
556561
planningMode: 'lite',
557562
requirePlanApproval: false,
563+
skipTests: true,
558564
});
559565

560566
const mockProvider = {

0 commit comments

Comments
 (0)