diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-19 11:27:35 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-19 11:27:35 +0300 |
commit | 7e9c479f7de77702622631cff2628a9c8dcbc627 (patch) | |
tree | c8f718a08e110ad7e1894510980d2155a6549197 /app/models/project_statistics.rb | |
parent | e852b0ae16db4052c1c567d9efa4facc81146e88 (diff) |
Add latest changes from gitlab-org/gitlab@13-6-stable-eev13.6.0-rc42
Diffstat (limited to 'app/models/project_statistics.rb')
-rw-r--r-- | app/models/project_statistics.rb | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/app/models/project_statistics.rb b/app/models/project_statistics.rb index 0d2f89fb18d..c11a7fea1c6 100644 --- a/app/models/project_statistics.rb +++ b/app/models/project_statistics.rb @@ -19,14 +19,14 @@ class ProjectStatistics < ApplicationRecord before_save :update_storage_size - COLUMNS_TO_REFRESH = [:repository_size, :wiki_size, :lfs_objects_size, :commit_count, :snippets_size].freeze + COLUMNS_TO_REFRESH = [:repository_size, :wiki_size, :lfs_objects_size, :commit_count, :snippets_size, :uploads_size].freeze INCREMENTABLE_COLUMNS = { build_artifacts_size: %i[storage_size], packages_size: %i[storage_size], pipeline_artifacts_size: %i[storage_size], snippets_size: %i[storage_size] }.freeze - NAMESPACE_RELATABLE_COLUMNS = [:repository_size, :wiki_size, :lfs_objects_size].freeze + NAMESPACE_RELATABLE_COLUMNS = [:repository_size, :wiki_size, :lfs_objects_size, :uploads_size].freeze scope :for_project_ids, ->(project_ids) { where(project_id: project_ids) } @@ -72,6 +72,12 @@ class ProjectStatistics < ApplicationRecord self.lfs_objects_size = project.lfs_objects.sum(:size) end + def update_uploads_size + return uploads_size unless Feature.enabled?(:count_uploads_size_in_storage_stats, project) + + self.uploads_size = project.uploads.sum(:size) + end + # `wiki_size` and `snippets_size` have no default value in the database # and the column can be nil. # This means that, when the columns were added, all rows had nil @@ -98,6 +104,10 @@ class ProjectStatistics < ApplicationRecord # might try to update project statistics before the `pipeline_artifacts_size` column has been created. storage_size += pipeline_artifacts_size if self.class.column_names.include?('pipeline_artifacts_size') + # The `uploads_size` column was added on 20201105021637 but db/post_migrate/20190527194900_schedule_calculate_wiki_sizes.rb + # might try to update project statistics before the `uploads_size` column has been created. + storage_size += uploads_size if self.class.column_names.include?('uploads_size') + self.storage_size = storage_size end |