summaryrefslogtreecommitdiff
path: root/app/models/service.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/service.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/service.rb')
-rw-r--r--app/models/service.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/app/models/service.rb b/app/models/service.rb
index 5432f8c7ab4..4821096379c 100644
--- a/app/models/service.rb
+++ b/app/models/service.rb
@@ -17,6 +17,7 @@ class Service < ActiveRecord::Base
after_commit :reset_updated_properties
after_commit :cache_project_has_external_issue_tracker
+ after_commit :cache_project_has_external_wiki
belongs_to :project, inverse_of: :services
has_one :service_hook
@@ -25,6 +26,7 @@ class Service < ActiveRecord::Base
scope :visible, -> { where.not(type: ['GitlabIssueTrackerService', 'GitlabCiService']) }
scope :issue_trackers, -> { where(category: 'issue_tracker') }
+ scope :external_wikis, -> { where(type: 'ExternalWikiService') }
scope :active, -> { where(active: true) }
scope :without_defaults, -> { where(default: false) }
@@ -212,4 +214,10 @@ class Service < ActiveRecord::Base
project.cache_has_external_issue_tracker
end
end
+
+ def cache_project_has_external_wiki
+ if project && !project.destroyed?
+ project.cache_has_external_wiki
+ end
+ end
end