Load merge request versions without loading whole diff from database

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent d99d5198
......@@ -30,6 +30,10 @@ class MergeRequestDiff < ActiveRecord::Base
# It allows you to override variables like head_commit_sha before getting diff.
after_create :save_git_content, unless: :importing?
def self.select_without_diff
select(column_names - ['st_diffs'])
end
# Collect information about commits and diff from repository
# and save it to the database as serialized data
def save_git_content
......
- diffs_count = @merge_request.merge_request_diffs.count
- merge_request_diffs = @merge_request.merge_request_diffs.select_without_diff
- latest_diff = merge_request_diffs.first
- if diffs_count > 1
- latest_diff = @merge_request.merge_request_diff
- if merge_request_diffs.size > 1
.mr-version-switch
Version:&nbsp;
%span.dropdown.inline
......@@ -13,7 +13,7 @@
#{@merge_request_diff.head_commit.short_id}
%span.caret
%ul.dropdown-menu.dropdown-menu-selectable
- @merge_request.merge_request_diffs.each do |merge_request_diff|
- merge_request_diffs.each do |merge_request_diff|
%li
= link_to diffs_namespace_project_merge_request_path(@project.namespace, @project, @merge_request, diff_id: merge_request_diff.id), class: ('is-active' if merge_request_diff == @merge_request_diff) do
%strong.monospace
......
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