diff options
author | Paco Guzman <pacoguzmanp@gmail.com> | 2016-07-21 15:11:46 +0200 |
---|---|---|
committer | Paco Guzman <pacoguzmanp@gmail.com> | 2016-07-21 16:00:27 +0200 |
commit | e223dc9260a64b3986ffefaf43201d6b0521c783 (patch) | |
tree | a0433eb6deb9d23658f98c6f534d963913c7d75a | |
parent | 41a9fdbe0493382dd75d9dcc35ad445e4a22d088 (diff) | |
download | gitlab-ce-20034-highlighted-diff-cached.tar.gz |
Cache Highlighted Diff Lines when reload MR content20034-highlighted-diff-cached
-rw-r--r-- | app/helpers/diff_helper.rb | 3 | ||||
-rw-r--r-- | app/models/merge_request.rb | 2 | ||||
-rw-r--r-- | app/services/merge_requests/merge_request_diff_cache_service.rb | 9 |
3 files changed, 13 insertions, 1 deletions
diff --git a/app/helpers/diff_helper.rb b/app/helpers/diff_helper.rb index 75b029365f9..b2af1294fe6 100644 --- a/app/helpers/diff_helper.rb +++ b/app/helpers/diff_helper.rb @@ -30,7 +30,8 @@ module DiffHelper options[:paths] = params.values_at(:old_path, :new_path) end - Commit.max_diff_options.merge(options) + # Select truthy values those are the ones that makes a change + Commit.max_diff_options.merge(options).select { |_, v| v } end def safe_diff_files(diffs, diff_refs: nil, repository: nil) diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb index daee7289c32..dfd93c6de10 100644 --- a/app/models/merge_request.rb +++ b/app/models/merge_request.rb @@ -342,6 +342,8 @@ class MergeRequest < ActiveRecord::Base merge_request_diff.reload_content + MergeRequests::MergeRequestDiffCacheService.new.execute(merge_request) + new_diff_refs = self.diff_refs update_diff_notes_positions( diff --git a/app/services/merge_requests/merge_request_diff_cache_service.rb b/app/services/merge_requests/merge_request_diff_cache_service.rb new file mode 100644 index 00000000000..e8e4cd13cd1 --- /dev/null +++ b/app/services/merge_requests/merge_request_diff_cache_service.rb @@ -0,0 +1,9 @@ +module MergeRequests + class MergeRequestDiffCacheService + def execute(merge_request) + # REVIEW how do we share default options here and in the controllers + # We store by calculating the cache + merge_request.highlighted_safe_diff_files(Commit.max_diff_options) + end + end +end |