Skip to content

Commit b6c5aeb

Browse files
abhishekmukhergclaudemcncllizrabuya
authored
⚡️ perf: optimize pipeline filtering by repository in API calls (#552)
Replace local filtering with repository-specific API requests to reduce data transfer and improve performance when filtering pipelines by repository URLs. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-authored-by: Claude <[email protected]> Co-authored-by: Ben McNicholl <[email protected]> Co-authored-by: Lizette Rabuya <[email protected]>
1 parent c79d940 commit b6c5aeb

File tree

1 file changed

+24
-21
lines changed

1 file changed

+24
-21
lines changed

internal/pipeline/resolver/repository.go

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -52,30 +52,33 @@ func filterPipelines(ctx context.Context, repoURLs []string, org string, client
5252
var currentPipelines []pipeline.Pipeline
5353
page := 1
5454
per_page := 30
55-
for more_pipelines := true; more_pipelines; {
56-
opts := buildkite.PipelineListOptions{
57-
ListOptions: buildkite.ListOptions{
58-
Page: page,
59-
PerPage: per_page,
60-
},
61-
}
55+
for _, repoURL := range repoURLs {
56+
for more_pipelines := true; more_pipelines; {
57+
opts := buildkite.PipelineListOptions{
58+
ListOptions: buildkite.ListOptions{
59+
Page: page,
60+
PerPage: per_page,
61+
},
62+
Repository: repoURL,
63+
}
6264

63-
pipelines, resp, err := client.Pipelines.List(ctx, org, &opts)
64-
if err != nil {
65-
return nil, err
66-
}
67-
for _, p := range pipelines {
68-
for _, u := range repoURLs {
69-
gitUrl := u[strings.LastIndex(u, "/")+1:]
70-
if strings.Contains(p.Repository, gitUrl) {
71-
currentPipelines = append(currentPipelines, pipeline.Pipeline{Name: p.Slug, Org: org})
65+
pipelines, resp, err := client.Pipelines.List(ctx, org, &opts)
66+
if err != nil {
67+
return nil, err
68+
}
69+
for _, p := range pipelines {
70+
for _, u := range repoURLs {
71+
gitUrl := u[strings.LastIndex(u, "/")+1:]
72+
if strings.Contains(p.Repository, gitUrl) {
73+
currentPipelines = append(currentPipelines, pipeline.Pipeline{Name: p.Slug, Org: org})
74+
}
7275
}
7376
}
74-
}
75-
if resp.NextPage == 0 {
76-
more_pipelines = false
77-
} else {
78-
page = resp.NextPage
77+
if resp.NextPage == 0 {
78+
more_pipelines = false
79+
} else {
80+
page = resp.NextPage
81+
}
7982
}
8083
}
8184
return currentPipelines, nil

0 commit comments

Comments
 (0)