Commit 63e532eff01ac927e7fa39781d9ebd61503c9a3e

Authored by Dmitriy Zaporozhets
1 parent 967d42e0

Cache MR diffs result. Improve diff output

1 -web: bundle exec puma -p $PORT 1 +web: bundle exec unicorn_rails -p $PORT -E development
2 worker: bundle exec sidekiq -q post_receive,mailer,system_hook,project_web_hook,common,default,gitlab_shell 2 worker: bundle exec sidekiq -q post_receive,mailer,system_hook,project_web_hook,common,default,gitlab_shell
app/controllers/projects/merge_requests_controller.rb
@@ -30,7 +30,6 @@ class Projects::MergeRequestsController < Projects::ApplicationController @@ -30,7 +30,6 @@ class Projects::MergeRequestsController < Projects::ApplicationController
30 end 30 end
31 31
32 def diffs 32 def diffs
33 - @diffs = @merge_request.diffs  
34 @commit = @merge_request.last_commit 33 @commit = @merge_request.last_commit
35 34
36 @comments_allowed = @reply_allowed = true 35 @comments_allowed = @reply_allowed = true
app/models/merge_request.rb
@@ -116,7 +116,7 @@ class MergeRequest < ActiveRecord::Base @@ -116,7 +116,7 @@ class MergeRequest < ActiveRecord::Base
116 end 116 end
117 117
118 def diffs 118 def diffs
119 - load_diffs(st_diffs) || [] 119 + @diffs ||= (load_diffs(st_diffs) || [])
120 end 120 end
121 121
122 def reloaded_diffs 122 def reloaded_diffs
@@ -128,6 +128,8 @@ class MergeRequest < ActiveRecord::Base @@ -128,6 +128,8 @@ class MergeRequest < ActiveRecord::Base
128 128
129 def broken_diffs? 129 def broken_diffs?
130 diffs == broken_diffs 130 diffs == broken_diffs
  131 + rescue
  132 + true
131 end 133 end
132 134
133 def valid_diffs? 135 def valid_diffs?
app/views/projects/merge_requests/_show.html.haml
@@ -21,7 +21,8 @@ @@ -21,7 +21,8 @@
21 .notes.tab-content.voting_notes#notes{ class: (controller.action_name == 'show') ? "" : "hide" } 21 .notes.tab-content.voting_notes#notes{ class: (controller.action_name == 'show') ? "" : "hide" }
22 = render "projects/notes/notes_with_form" 22 = render "projects/notes/notes_with_form"
23 .diffs.tab-content 23 .diffs.tab-content
24 - = render "projects/merge_requests/show/diffs" if @diffs 24 + - if current_page?(action: 'diffs')
  25 + = render "projects/merge_requests/show/diffs"
25 .status 26 .status
26 27
27 :javascript 28 :javascript
app/views/projects/merge_requests/show/_diffs.html.haml
1 - if @merge_request.valid_diffs? 1 - if @merge_request.valid_diffs?
2 - = render "projects/commits/diffs", diffs: @diffs 2 + = render "projects/commits/diffs", diffs: @merge_request.diffs
3 - elsif @merge_request.broken_diffs? 3 - elsif @merge_request.broken_diffs?
4 %h4.nothing_here_message 4 %h4.nothing_here_message
5 Can't load diff. 5 Can't load diff.
doc/install/installation.md
@@ -184,11 +184,11 @@ You can change `5-3-stable` to `master` if you want the *bleeding edge* version, @@ -184,11 +184,11 @@ You can change `5-3-stable` to `master` if you want the *bleeding edge* version,
184 sudo chmod -R u+rwX public/uploads 184 sudo chmod -R u+rwX public/uploads
185 185
186 # Copy the example Puma config 186 # Copy the example Puma config
187 - sudo -u git -H cp config/puma.rb.example config/puma.rb 187 + sudo -u git -H cp config/unicorn.rb.example config/unicorn.rb
188 188
189 # Enable cluster mode if you expect to have a high load instance 189 # Enable cluster mode if you expect to have a high load instance
190 # Ex. change amount of workers to 3 for 2GB RAM server 190 # Ex. change amount of workers to 3 for 2GB RAM server
191 - sudo -u git -H vim config/puma.rb 191 + sudo -u git -H vim config/unicorn.rb
192 192
193 # Configure Git global settings for git user, useful when editing via web 193 # Configure Git global settings for git user, useful when editing via web
194 # Edit user.email according to what is set in gitlab.yml 194 # Edit user.email according to what is set in gitlab.yml
@@ -196,7 +196,7 @@ You can change `5-3-stable` to `master` if you want the *bleeding edge* version, @@ -196,7 +196,7 @@ You can change `5-3-stable` to `master` if you want the *bleeding edge* version,
196 sudo -u git -H git config --global user.email "gitlab@localhost" 196 sudo -u git -H git config --global user.email "gitlab@localhost"
197 197
198 **Important Note:** 198 **Important Note:**
199 -Make sure to edit both `gitlab.yml` and `puma.rb` to match your setup. 199 +Make sure to edit both `gitlab.yml` and `unicorn.rb` to match your setup.
200 200
201 ## Configure GitLab DB settings 201 ## Configure GitLab DB settings
202 202