Speed up `all_commit_shas` for new merge requests
What does this MR do?
Dramatically - MergeRequest#all_commit_shas
when the MR has commits in the new table added in https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/12527.
Are there points in the code the reviewer needs to double check?
I thought this would be a more clunky interface change, but actually it's pretty OK!
Why was this MR needed?
Using mixed
from https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/12527#note_34317014:
# New method
Benchmark.realtime { 10.times { mixed.all_commit_shas } }
#=> 43.5131490000058
# Old method
Benchmark.realtime { 10.times { mixed.merge_request_diffs.preload(:merge_request_diff_commits).flat_map(&:commit_shas).uniq } }
#=> 62.56671699997969
# Just for fun!
Benchmark.realtime { 10.times { new.all_commit_shas } }
#=> 0.3927479999838397
Screenshots (if relevant)
Does this MR meet the acceptance criteria?
-
Changelog entry added, if necessary - Tests
-
All builds are passing
-
-
Conform by the merge request performance guides -
Conform by the style guides -
Branch has no merge conflicts with master
(if it does - rebase it please) -
Squashed related commits together
Edited by username-removed-443319