diff options
author | Douwe Maan <douwe@gitlab.com> | 2017-07-07 17:42:42 +0300 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2017-07-07 17:42:42 +0300 |
commit | 1a3edcec4363239a4d080bc9af53d9d455dccfb4 (patch) | |
tree | 8bfa139415440f6959c4195213a07ba02f71c722 /app | |
parent | 4ccdb83ae489014e671c3fbe75a4d899913c5163 (diff) | |
parent | 4c0864fd9e14cda78cacdfbbc2f3072b699ebb9b (diff) |
Merge branch 'speed-up-merge-request-all-commits-shas' into 'master'
Speed up `all_commit_shas` for new merge requests
See merge request !12706
Diffstat (limited to 'app')
-rw-r--r-- | app/models/merge_request.rb | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb index 2fc6191e785..6ea774470af 100644 --- a/app/models/merge_request.rb +++ b/app/models/merge_request.rb @@ -849,7 +849,10 @@ class MergeRequest < ActiveRecord::Base # def all_commit_shas if persisted? - merge_request_diffs.preload(:merge_request_diff_commits).flat_map(&:commit_shas).uniq + column_shas = MergeRequestDiffCommit.where(merge_request_diff: merge_request_diffs).pluck('DISTINCT(sha)') + serialised_shas = merge_request_diffs.where.not(st_commits: nil).flat_map(&:commit_shas) + + (column_shas + serialised_shas).uniq elsif compare_commits compare_commits.to_a.reverse.map(&:id) else |