diff options
author | Paco Guzman <pacoguzmanp@gmail.com> | 2016-10-13 13:01:27 +0200 |
---|---|---|
committer | Paco Guzman <pacoguzmanp@gmail.com> | 2016-10-18 08:13:52 +0200 |
commit | 6a16697ad29bc2136411faf2431baa94f2a599e0 (patch) | |
tree | 0749e043e7fe3d89fc0bc3c670c8586a30a4972a /app/helpers | |
parent | 4e6af0c3fa335d138343dce3e0216303a9b1cd79 (diff) | |
download | gitlab-ce-faster_toggle_award_url_helper_method.tar.gz |
Execute specific named route method from toggle_award_url helper methodfaster_toggle_award_url_helper_method
Diffstat (limited to 'app/helpers')
-rw-r--r-- | app/helpers/award_emoji_helper.rb | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/app/helpers/award_emoji_helper.rb b/app/helpers/award_emoji_helper.rb index aa134cea31c..493f14f6f9d 100644 --- a/app/helpers/award_emoji_helper.rb +++ b/app/helpers/award_emoji_helper.rb @@ -1,9 +1,12 @@ module AwardEmojiHelper def toggle_award_url(awardable) - if @project - url_for([:toggle_award_emoji, @project.namespace.becomes(Namespace), @project, awardable]) + return url_for([:toggle_award_emoji, awardable]) unless @project + + if awardable.is_a?(Note) + # We render a list of notes very frequently and calling the specific method is a lot faster than the generic one (6.5x) + toggle_award_emoji_namespace_project_note_url(namespace_id: @project.namespace_id, project_id: @project.id, id: awardable.id) else - url_for([:toggle_award_emoji, awardable]) + url_for([:toggle_award_emoji, @project.namespace.becomes(Namespace), @project, awardable]) end end end |