Commit 93eb59c7 authored by Igor Drozdov's avatar Igor Drozdov

Improve performance of commits endpoint

Currently all the commits of a merge request is loaded
into the memory, converted to CommitCollection and
then paginated as an array

We can dramatically improve the performance by
paginating the diff commits first and then convert
this smaller array into CommitCollection
parent 37a02fdd
......@@ -296,9 +296,12 @@ module API
end
get ':id/merge_requests/:merge_request_iid/commits' do
merge_request = find_merge_request_with_access(params[:merge_request_iid])
commits = ::Kaminari.paginate_array(merge_request.commits)
present paginate(commits), with: Entities::Commit
commits =
paginate(merge_request.merge_request_diff.merge_request_diff_commits)
.map { |commit| Commit.from_hash(commit.to_hash, merge_request.project) }
present commits, with: Entities::Commit
end
desc 'Show the merge request changes' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment