Skip to content

improve performance of [GithubLastCommit] [GitlabLastCommit] [GiteaLastCommit] #10046

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

Merged
merged 2 commits into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion services/gitea/gitea-last-commit.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export default class GiteaLastCommit extends GiteaBase {
return super.fetch({
schema,
url: `${baseUrl}/api/v1/repos/${user}/${repo}/commits`,
options: { searchParams: { sha: branch, path } },
options: { searchParams: { sha: branch, path, limit: 1 } },
httpErrors: httpErrorsFor(),
})
}
Expand Down
2 changes: 1 addition & 1 deletion services/github/github-last-commit.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export default class GithubLastCommit extends GithubAuthV3Service {

async handle({ user, repo, branch }, queryParams) {
const { path, display_timestamp: displayTimestamp } = queryParams
const body = await this.fetch({ user, repo, branch, path })
const body = await this.fetch({ user, repo, branch, path, per_page: 1 })
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this not need to go in fetch here like your GitLab change?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch! thanks for the review

const [commit] = body.map(obj => obj.commit)

if (!commit) throw new NotFound({ prettyMessage: 'no commits found' })
Expand Down
2 changes: 1 addition & 1 deletion services/gitlab/gitlab-last-commit.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export default class GitlabLastCommit extends GitLabBase {
url: `${baseUrl}/api/v4/projects/${encodeURIComponent(
project,
)}/repository/commits`,
options: { searchParams: { ref_name: ref, path } },
options: { searchParams: { ref_name: ref, path, per_page: 1 } },
schema,
httpErrors: httpErrorsFor('project not found'),
})
Expand Down