Class: NamespaceStatistics
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- NamespaceStatistics
- Includes:
- AfterCommitQueue
- Defined in:
- app/models/namespace_statistics.rb
Overview
rubocop:disable Gitlab/NamespacedClass
Constant Summary
Constants inherited from ApplicationRecord
Constants included from HasCheckConstraints
HasCheckConstraints::NOT_NULL_CHECK_PATTERN
Constants included from ResetOnColumnErrors
ResetOnColumnErrors::MAX_RESET_PERIOD
Class Method Summary collapse
Instance Method Summary collapse
Methods included from AfterCommitQueue
#run_after_commit, #run_after_commit_or_now
Methods inherited from ApplicationRecord
===, cached_column_list, #create_or_load_association, declarative_enum, default_select_columns, id_in, id_not_in, iid_in, nullable_column?, pluck_primary_key, primary_key_in, #readable_by?, safe_ensure_unique, safe_find_or_create_by, safe_find_or_create_by!, #to_ability_name, underscore, where_exists, where_not_exists, with_fast_read_statement_timeout, without_order
Methods included from ResetOnColumnErrors
#reset_on_union_error, #reset_on_unknown_attribute_error
Methods included from Gitlab::SensitiveSerializableHash
Class Method Details
.columns_to_refresh ⇒ Object
49 50 51 |
# File 'app/models/namespace_statistics.rb', line 49 def self.columns_to_refresh [:dependency_proxy_size] end |
Instance Method Details
#refresh!(only: []) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/models/namespace_statistics.rb', line 18 def refresh!(only: []) return if Gitlab::Database.read_only? return unless group_namespace? self.class.columns_to_refresh.each do |column| if only.empty? || only.include?(column) public_send("update_#{column}") # rubocop:disable GitlabSecurity/PublicSend end end save! end |
#update_dependency_proxy_size ⇒ Object
39 40 41 42 43 44 45 46 47 |
# File 'app/models/namespace_statistics.rb', line 39 def update_dependency_proxy_size return unless group_namespace? self.dependency_proxy_size = [ namespace.dependency_proxy_manifests, namespace.dependency_proxy_blobs, ::VirtualRegistries::Packages::Maven::CachedResponse.for_group(namespace) ].sum { |rel| rel.sum(:size) } end |
#update_storage_size ⇒ Object
31 32 33 34 35 36 37 |
# File 'app/models/namespace_statistics.rb', line 31 def update_storage_size # This prevents failures with older database schemas, such as those # in migration specs. return unless self.class.database.cached_column_exists?(:dependency_proxy_size) self.storage_size = dependency_proxy_size end |