Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Github BranchService only returns 1 page of results #152

Open
psigourney opened this issue Apr 18, 2023 · 0 comments
Open

Github BranchService only returns 1 page of results #152

psigourney opened this issue Apr 18, 2023 · 0 comments

Comments

@psigourney
Copy link

psigourney commented Apr 18, 2023

val branches = with(githubFeignClient) {
getOwnerRepoFromUrl(pipeline.url).let { (owner, repo) ->
retrieveBranches(
pipeline.credential,
owner,
repo,
)
}
}

Github API Docs: https://docs.github.com/en/rest/branches/branches#list-branches
Based on the GH API, only the first 30 branches will be returned by the BranchService.

fun getNewRuns(pipeline: PipelineConfiguration, emitCb: (SyncProgress) -> Unit): MutableList<GithubActionsRun> {
val latestTimestamp = getLatestBuildTimeStamp(pipeline)
val newRuns = runService.syncRunsByPage(pipeline, latestTimestamp, emitCb)
val branches = branchService.retrieveBranches(pipeline)
return newRuns.filter { branches.contains(it.branch) } as MutableList<GithubActionsRun>
}

I'm not really sure why we're pulling the branches and filtering on them to begin with (if a run was executed on a specific branch, then that branch was later deleted, we'd still want to capture the run, right?), but if the branch filter is required (could someone reply with an explanation?), it might make sense to apply some pagination logic to the BranchService, similar to the logic used in syncRunsByPage:

https://github.com/thoughtworks/metrik/blob/main/backend/src/main/kotlin/metrik/project/domain/service/githubactions/RunService.kt#L19

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant