Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabriel Mazetto <brodock@gmail.com>2018-07-05 18:46:10 +0300
committerGabriel Mazetto <brodock@gmail.com>2018-07-24 19:44:07 +0300
commitc084e87ad7be45f39a79347b306f03f618705049 (patch)
treec6825ff5b5de1922d9d1ac042045a77a73c89b4a /app/models/project.rb
parent08d7ee65e7a16d6898d61758bffc70899b574065 (diff)
Added SiteStatistics as counter cache for Projects and Wikis
Diffstat (limited to 'app/models/project.rb')
-rw-r--r--app/models/project.rb5
1 files changed, 5 insertions, 0 deletions
diff --git a/app/models/project.rb b/app/models/project.rb
index f880d728839..32315dfaa01 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -31,6 +31,7 @@ class Project < ActiveRecord::Base
BoardLimitExceeded = Class.new(StandardError)
+ STATISTICS_ATTRIBUTE = 'repositories_count'.freeze
NUMBER_OF_PERMITTED_BOARDS = 1
UNKNOWN_IMPORT_URL = 'http://unknown.git'.freeze
# Hashed Storage versions handle rolling out new storage to project and dependents models:
@@ -79,6 +80,10 @@ class Project < ActiveRecord::Base
after_create :create_project_feature, unless: :project_feature
+ after_create -> { SiteStatistic.track(STATISTICS_ATTRIBUTE) }
+ before_destroy ->(project) { project.project_feature.untrack_statistics_for_deletion! }
+ after_destroy -> { SiteStatistic.untrack(STATISTICS_ATTRIBUTE) }
+
after_create :create_ci_cd_settings,
unless: :ci_cd_settings,
if: proc { ProjectCiCdSetting.available? }