BigW Consortium Gitlab

Load merge request versions without loading whole diff from database

parent d99d5198
...@@ -30,6 +30,10 @@ class MergeRequestDiff < ActiveRecord::Base ...@@ -30,6 +30,10 @@ class MergeRequestDiff < ActiveRecord::Base
# It allows you to override variables like head_commit_sha before getting diff. # It allows you to override variables like head_commit_sha before getting diff.
after_create :save_git_content, unless: :importing? 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 # Collect information about commits and diff from repository
# and save it to the database as serialized data # and save it to the database as serialized data
def save_git_content 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 - if merge_request_diffs.size > 1
- latest_diff = @merge_request.merge_request_diff
.mr-version-switch .mr-version-switch
Version:&nbsp; Version:&nbsp;
%span.dropdown.inline %span.dropdown.inline
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
#{@merge_request_diff.head_commit.short_id} #{@merge_request_diff.head_commit.short_id}
%span.caret %span.caret
%ul.dropdown-menu.dropdown-menu-selectable %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 %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 = 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 %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