summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorYorick Peterse <yorickpeterse@gmail.com>2016-03-24 17:00:26 +0100
committerYorick Peterse <yorickpeterse@gmail.com>2016-04-01 11:13:48 +0200
commit84b0ab77667b85a42db8a5a02d9758657af66f16 (patch)
tree5058f048563c8d8e8be4b7e0837d919ff0a878d4 /app/models
parent82539cff700931532b22b6a8e3d6832137fc5d55 (diff)
downloadgitlab-ce-84b0ab77667b85a42db8a5a02d9758657af66f16.tar.gz
Added & use Gitlab::Routing for URL helpersrouting
Rails' "url_helpers" method creates an anonymous Module (which a bunch of methods) on every call. By caching the output of this method in a dedicated method we can shave off about 10 seconds of loading time for an issue with around 200 comments.
Diffstat (limited to 'app/models')
-rw-r--r--app/models/milestone.rb2
-rw-r--r--app/models/project.rb4
-rw-r--r--app/models/project_services/gitlab_issue_tracker_service.rb2
-rw-r--r--app/models/project_services/jira_service.rb2
4 files changed, 5 insertions, 5 deletions
diff --git a/app/models/milestone.rb b/app/models/milestone.rb
index bbd59eab9ae..a5d92519b4c 100644
--- a/app/models/milestone.rb
+++ b/app/models/milestone.rb
@@ -89,7 +89,7 @@ class Milestone < ActiveRecord::Base
def to_reference(from_project = nil)
escaped_title = self.title.gsub("]", "\\]")
- h = Gitlab::Application.routes.url_helpers
+ h = Gitlab::Routing.url_helpers
url = h.namespace_project_milestone_url(self.project.namespace, self.project, self)
"[#{escaped_title}](#{url})"
diff --git a/app/models/project.rb b/app/models/project.rb
index f208965086d..c5022fd4ffc 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -471,7 +471,7 @@ class Project < ActiveRecord::Base
end
def web_url
- Gitlab::Application.routes.url_helpers.namespace_project_url(self.namespace, self)
+ Gitlab::Routing.url_helpers.namespace_project_url(self.namespace, self)
end
def web_url_without_protocol
@@ -592,7 +592,7 @@ class Project < ActiveRecord::Base
if avatar.present?
[gitlab_config.url, avatar.url].join
elsif avatar_in_git
- Gitlab::Application.routes.url_helpers.namespace_project_avatar_url(namespace, self)
+ Gitlab::Routing.url_helpers.namespace_project_avatar_url(namespace, self)
end
end
diff --git a/app/models/project_services/gitlab_issue_tracker_service.rb b/app/models/project_services/gitlab_issue_tracker_service.rb
index 05436cd0f79..eaa5654b9c6 100644
--- a/app/models/project_services/gitlab_issue_tracker_service.rb
+++ b/app/models/project_services/gitlab_issue_tracker_service.rb
@@ -20,7 +20,7 @@
#
class GitlabIssueTrackerService < IssueTrackerService
- include Gitlab::Application.routes.url_helpers
+ include Gitlab::Routing.url_helpers
prop_accessor :title, :description, :project_url, :issues_url, :new_issue_url
diff --git a/app/models/project_services/jira_service.rb b/app/models/project_services/jira_service.rb
index aba37921c09..1ed42c4f3e7 100644
--- a/app/models/project_services/jira_service.rb
+++ b/app/models/project_services/jira_service.rb
@@ -21,7 +21,7 @@
class JiraService < IssueTrackerService
include HTTParty
- include Gitlab::Application.routes.url_helpers
+ include Gitlab::Routing.url_helpers
DEFAULT_API_VERSION = 2