diff options
author | Robert Speicher <robert@gitlab.com> | 2017-12-19 16:23:00 +0000 |
---|---|---|
committer | Robert Speicher <robert@gitlab.com> | 2017-12-19 16:23:00 +0000 |
commit | ac22576d80b6d043c4991ad39172976566465693 (patch) | |
tree | 06b4041a313cfabab35373c765cec56566000cb0 /lib | |
parent | 4e60b4f1cdfa7dc3524d17bf313d348758950ecf (diff) | |
parent | c6edae38870a4228e3b964d647b9ef588df11f27 (diff) | |
download | gitlab-ce-ac22576d80b6d043c4991ad39172976566465693.tar.gz |
Merge branch 'zj-gitaly-pipelines-n-1' into 'master'
Improve performance of Pipelines#index.json
See merge request gitlab-org/gitlab-ce!14846
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/git/commit.rb | 13 | ||||
-rw-r--r-- | lib/gitlab/gitaly_client/commit_service.rb | 9 |
2 files changed, 22 insertions, 0 deletions
diff --git a/lib/gitlab/git/commit.rb b/lib/gitlab/git/commit.rb index e90b158fb34..145721dea76 100644 --- a/lib/gitlab/git/commit.rb +++ b/lib/gitlab/git/commit.rb @@ -228,6 +228,19 @@ module Gitlab end end end + + # Only to be used when the object ids will not necessarily have a + # relation to each other. The last 10 commits for a branch for example, + # should go through .where + def batch_by_oid(repo, oids) + repo.gitaly_migrate(:list_commits_by_oid) do |is_enabled| + if is_enabled + repo.gitaly_commit_client.list_commits_by_oid(oids) + else + oids.map { |oid| find(repo, oid) }.compact + end + end + end end def initialize(repository, raw_commit, head = nil) diff --git a/lib/gitlab/gitaly_client/commit_service.rb b/lib/gitlab/gitaly_client/commit_service.rb index 7985f5b5457..fb3e27770b4 100644 --- a/lib/gitlab/gitaly_client/commit_service.rb +++ b/lib/gitlab/gitaly_client/commit_service.rb @@ -169,6 +169,15 @@ module Gitlab consume_commits_response(response) end + def list_commits_by_oid(oids) + request = Gitaly::ListCommitsByOidRequest.new(repository: @gitaly_repo, oid: oids) + + response = GitalyClient.call(@repository.storage, :commit_service, :list_commits_by_oid, request, timeout: GitalyClient.medium_timeout) + consume_commits_response(response) + rescue GRPC::Unknown # If no repository is found, happens mainly during testing + [] + end + def commits_by_message(query, revision: '', path: '', limit: 1000, offset: 0) request = Gitaly::CommitsByMessageRequest.new( repository: @gitaly_repo, |