summaryrefslogtreecommitdiff
path: root/app/models/project.rb
diff options
context:
space:
mode:
authorEugene Howe <eugene@xtreme-computers.net>2016-07-17 10:32:11 -0400
committerEugene Howe <eugene@xtreme-computers.net>2016-07-19 09:06:58 -0400
commit13e74543f9d0f91b7b3ef14279fd78d83f442750 (patch)
tree2113950412eb9a83d3f0bc5bdc1aaee60661e06c /app/models/project.rb
parent61e7453e0465ceb631d3e8445429cfed7c1449d3 (diff)
downloadgitlab-ce-13e74543f9d0f91b7b3ef14279fd78d83f442750.tar.gz
speed up ExternalWikiService#get_project_wiki_path
* This method previously iterated over all services in a project. Now it will directly query the ExternalWikiService for the project and filter by active state. * The presence of an external wiki is also cached * When an external wiki is added or removed, the cached value is updated
Diffstat (limited to 'app/models/project.rb')
-rw-r--r--app/models/project.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/app/models/project.rb b/app/models/project.rb
index a805f5d97bc..d08b737e813 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -650,6 +650,22 @@ class Project < ActiveRecord::Base
update_column(:has_external_issue_tracker, services.external_issue_trackers.any?)
end
+ def external_wiki
+ if has_external_wiki.nil?
+ cache_has_external_wiki # Populate
+ end
+
+ if has_external_wiki
+ @external_wiki ||= services.external_wikis.first
+ else
+ nil
+ end
+ end
+
+ def cache_has_external_wiki
+ update_column(:has_external_wiki, services.external_wikis.any?)
+ end
+
def build_missing_services
services_templates = Service.where(template: true)