summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabriel Mazetto <brodock@gmail.com>2018-08-23 23:54:43 +0200
committerGabriel Mazetto <brodock@gmail.com>2018-08-24 00:57:50 +0200
commita32a410fb9bfcd378840b61426a54fd56d2ebd33 (patch)
tree7df1adca0277b554a16312181aaa75877efe3961
parent931600836b03076195f0a8df413eb546bf6353ca (diff)
downloadgitlab-ce-a32a410fb9bfcd378840b61426a54fd56d2ebd33.tar.gz
Move wiki statistics deletion to after_destroy
-rw-r--r--app/models/project.rb9
1 files changed, 7 insertions, 2 deletions
diff --git a/app/models/project.rb b/app/models/project.rb
index 8f631d7f0ed..37231df979e 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -85,8 +85,8 @@ 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) }
+ before_destroy ->(project) { project.project_feature } # keep reference so we can untrack later
+ after_destroy :untrack_site_statistics
after_create :create_ci_cd_settings,
unless: :ci_cd_settings,
@@ -2093,6 +2093,11 @@ class Project < ActiveRecord::Base
Gitlab::PagesTransfer.new.rename_project(path_before, self.path, namespace.full_path)
end
+ def untrack_site_statistics
+ SiteStatistic.untrack(STATISTICS_ATTRIBUTE)
+ SiteStatistic.project_feature.untrack_statistics_for_deletion!
+ end
+
def execute_rename_repository_hooks!(full_path_before)
# When we import a project overwriting the original project, there
# is a move operation. In that case we don't want to send the instructions.