diff options
author | Paco Guzman <pacoguzmanp@gmail.com> | 2016-06-03 11:21:18 +0300 |
---|---|---|
committer | Yorick Peterse <yorickpeterse@gmail.com> | 2016-06-10 16:41:56 +0300 |
commit | 136a4ea39bb82d7e88b79a3bb7b2f3b4a5ec42ab (patch) | |
tree | eb0aef01f6b7eb2da95434501b860c2738dd3a5f /app/models/service.rb | |
parent | f29fd65cdde1d769fc89f0cc57ea989765b5068f (diff) |
Cache the presence of an issue_tracker at project level
Using update_column to store the boolean flag to avoid
any side effects with the current state of the project
instance
Diffstat (limited to 'app/models/service.rb')
-rw-r--r-- | app/models/service.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/app/models/service.rb b/app/models/service.rb index de3fd24584a..bf352397509 100644 --- a/app/models/service.rb +++ b/app/models/service.rb @@ -16,6 +16,7 @@ class Service < ActiveRecord::Base after_initialize :initialize_properties after_commit :reset_updated_properties + after_commit :cache_project_has_external_issue_tracker belongs_to :project has_one :service_hook @@ -34,6 +35,7 @@ class Service < ActiveRecord::Base scope :note_hooks, -> { where(note_events: true, active: true) } scope :build_hooks, -> { where(build_events: true, active: true) } scope :wiki_page_hooks, -> { where(wiki_page_events: true, active: true) } + scope :external_issue_trackers, -> { issue_trackers.active.without_defaults } default_value_for :category, 'common' @@ -192,4 +194,12 @@ class Service < ActiveRecord::Base service.project_id = project_id service if service.save end + + private + + def cache_project_has_external_issue_tracker + if project && !project.destroyed? + project.cache_has_external_issue_tracker + end + end end |