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

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

Merged
merged 2 commits into from
Mar 25, 2024

Conversation

chris48s
Copy link
Member

This is something I noticed while I was testing #10041
It isn't a new problem introduced by that PR, so I decided not to scope creep it there.

Basically the deal here is we only care about the most recent commit, but we're requesting an entire page of results to just use the first object. Only requesting the most recent one means we can request less data from the upstream and render the badge faster. Note this optimisation doesn't work in all situations. Specifically, Gitea ignores limit when the path param is also supplied (see https://docs.gitea.com/api/1.20/#tag/repository/operation/repoGetAllCommits ), but we might as well do this whenever we can.

Note that @ReubenFrankel has already applied the equivalent optimisation in #10043 👍 which adds the corresponding BitBucket badges.

@chris48s chris48s added the service-badge Accepted and actionable changes, features, and bugs label Mar 25, 2024
Copy link
Contributor

github-actions bot commented Mar 25, 2024

Warnings
⚠️ This PR modified service code for gitea but not its test code.
That's okay so long as it's refactoring existing code.
⚠️ This PR modified service code for github but not its test code.
That's okay so long as it's refactoring existing code.
⚠️ This PR modified service code for gitlab but not its test code.
That's okay so long as it's refactoring existing code.
Messages
📖 ✨ Thanks for your contribution to Shields, @chris48s!

Generated by 🚫 dangerJS against 6630a5a

@@ -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

@chris48s chris48s merged commit 3c60625 into badges:master Mar 25, 2024
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
service-badge Accepted and actionable changes, features, and bugs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants