diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-06-25 08:14:03 +0000 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-06-25 08:14:03 +0000 |
commit | 0c8b96bdbc5c9f92d7a1e1227498cd2cc00d19ac (patch) | |
tree | 63e9d6828b43e8c4f8d01d137cb1ebb3b8fab50d /app/views | |
parent | d2de219f6cf5d6ce371f529988f9337653878e58 (diff) | |
parent | 82f372c719b7564fa09f23bef1e6d4c61c8ece4b (diff) | |
download | gitlab-ce-0c8b96bdbc5c9f92d7a1e1227498cd2cc00d19ac.tar.gz |
Merge branch 'performance-improvements' into 'master'
Performance improvements
* store @participants in variable
* store result of subscribed? call into variable
In total it reduce amount of SQL queries for issue or merge_request with 10 comments/participants almost twice.
See merge request !883
Diffstat (limited to 'app/views')
4 files changed, 14 insertions, 12 deletions
diff --git a/app/views/projects/issues/_discussion.html.haml b/app/views/projects/issues/_discussion.html.haml index 48858fa32da..656e06ca105 100644 --- a/app/views/projects/issues/_discussion.html.haml +++ b/app/views/projects/issues/_discussion.html.haml @@ -12,8 +12,8 @@ .votes-holder.pull-right #votes= render 'votes/votes_block', votable: @issue .participants - %span= pluralize(@issue.participants(current_user).count, 'participant') - - @issue.participants(current_user).each do |participant| + %span= pluralize(@participants.count, 'participant') + - @participants.each do |participant| = link_to_member(@project, participant, name: false, size: 24) .voting_notes#notes= render 'projects/notes/notes_with_form' %aside.col-md-3 diff --git a/app/views/projects/issues/_issue_context.html.haml b/app/views/projects/issues/_issue_context.html.haml index 323f5c84a85..88b63946905 100644 --- a/app/views/projects/issues/_issue_context.html.haml +++ b/app/views/projects/issues/_issue_context.html.haml @@ -28,18 +28,19 @@ = f.submit class: 'btn' - if current_user + - subscribed = @issue.subscribed?(current_user) %div.prepend-top-20.clearfix .issuable-context-title %label Subscription: %button.btn.btn-block.subscribe-button{:type => 'button'} %i.fa.fa-eye - %span= @issue.subscribed?(current_user) ? "Unsubscribe" : "Subscribe" - - subscribtion_status = @issue.subscribed?(current_user) ? "subscribed" : "unsubscribed" + %span= subscribed ? "Unsubscribe" : "Subscribe" + - subscribtion_status = subscribed ? "subscribed" : "unsubscribed" .subscription-status{"data-status" => subscribtion_status} - .description-block.unsubscribed{class: ( "hidden" if @issue.subscribed?(current_user) )} + .description-block.unsubscribed{class: ( "hidden" if subscribed )} You're not receiving notifications from this thread. - .description-block.subscribed{class: ( "hidden" unless @issue.subscribed?(current_user) )} + .description-block.subscribed{class: ( "hidden" unless subscribed )} You're receiving notifications because you're subscribed to this thread. :coffeescript diff --git a/app/views/projects/merge_requests/show/_context.html.haml b/app/views/projects/merge_requests/show/_context.html.haml index 1d0e2e350b0..5f2f65e0087 100644 --- a/app/views/projects/merge_requests/show/_context.html.haml +++ b/app/views/projects/merge_requests/show/_context.html.haml @@ -30,18 +30,19 @@ = f.submit class: 'btn' - if current_user + - subscribed = @merge_request.subscribed?(current_user) %div.prepend-top-20.clearfix .issuable-context-title %label Subscription: %button.btn.btn-block.subscribe-button{:type => 'button'} = icon('eye') - %span= @merge_request.subscribed?(current_user) ? 'Unsubscribe' : 'Subscribe' - - subscribtion_status = @merge_request.subscribed?(current_user) ? 'subscribed' : 'unsubscribed' + %span= subscribed ? 'Unsubscribe' : 'Subscribe' + - subscribtion_status = subscribed ? 'subscribed' : 'unsubscribed' .subscription-status{data: {status: subscribtion_status}} - .description-block.unsubscribed{class: ( 'hidden' if @merge_request.subscribed?(current_user) )} + .description-block.unsubscribed{class: ( 'hidden' if subscribed )} You're not receiving notifications from this thread. - .description-block.subscribed{class: ( 'hidden' unless @merge_request.subscribed?(current_user) )} + .description-block.subscribed{class: ( 'hidden' unless subscribed )} You're receiving notifications because you're subscribed to this thread. :coffeescript diff --git a/app/views/projects/merge_requests/show/_participants.html.haml b/app/views/projects/merge_requests/show/_participants.html.haml index 9c93fa55fe6..c67afe963e7 100644 --- a/app/views/projects/merge_requests/show/_participants.html.haml +++ b/app/views/projects/merge_requests/show/_participants.html.haml @@ -1,4 +1,4 @@ .participants - %span #{@merge_request.participants(current_user).count} participants - - @merge_request.participants(current_user).each do |participant| + %span #{@participants.count} participants + - @participants.each do |participant| = link_to_member(@project, participant, name: false, size: 24) |