From 3c60625c5176d55462a66c9b8b7412d291348a79 Mon Sep 17 00:00:00 2001
From: chris48s <chris48s@users.noreply.github.com>
Date: Mon, 25 Mar 2024 15:12:28 +0000
Subject: [PATCH] improve performance of [GithubLastCommit] [GitlabLastCommit]
 [GiteaLastCommit] (#10046)

* improve performance of last commit badges

* pass param in the right place
---
 services/gitea/gitea-last-commit.service.js   | 2 +-
 services/github/github-last-commit.service.js | 2 +-
 services/gitlab/gitlab-last-commit.service.js | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/services/gitea/gitea-last-commit.service.js b/services/gitea/gitea-last-commit.service.js
index bf9c3c28df..9a6377e8f2 100644
--- a/services/gitea/gitea-last-commit.service.js
+++ b/services/gitea/gitea-last-commit.service.js
@@ -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(),
     })
   }
diff --git a/services/github/github-last-commit.service.js b/services/github/github-last-commit.service.js
index b0fb5d4fc4..fa989229c2 100644
--- a/services/github/github-last-commit.service.js
+++ b/services/github/github-last-commit.service.js
@@ -98,7 +98,7 @@ export default class GithubLastCommit extends GithubAuthV3Service {
   async fetch({ user, repo, branch, path }) {
     return this._requestJson({
       url: `/repos/${user}/${repo}/commits`,
-      options: { searchParams: { sha: branch, path } },
+      options: { searchParams: { sha: branch, path, per_page: 1 } },
       schema,
       httpErrors: httpErrorsFor(),
     })
diff --git a/services/gitlab/gitlab-last-commit.service.js b/services/gitlab/gitlab-last-commit.service.js
index af17127296..b97c300beb 100644
--- a/services/gitlab/gitlab-last-commit.service.js
+++ b/services/gitlab/gitlab-last-commit.service.js
@@ -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'),
     })
-- 
GitLab