Class: SnippetStatistics
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- SnippetStatistics
- Includes:
- AfterCommitQueue, UpdateProjectStatistics
- Defined in:
- app/models/snippet_statistics.rb
Constant Summary
Constants inherited from ApplicationRecord
Constants included from HasCheckConstraints
HasCheckConstraints::NOT_NULL_CHECK_PATTERN
Constants included from ResetOnColumnErrors
ResetOnColumnErrors::MAX_RESET_PERIOD
Instance Method Summary collapse
- #refresh! ⇒ Object
- #update_commit_count ⇒ Object
- #update_file_count ⇒ Object
- #update_repository_size ⇒ Object
Methods included from AfterCommitQueue
#run_after_commit, #run_after_commit_or_now
Methods inherited from ApplicationRecord
===, cached_column_list, #create_or_load_association, current_transaction, declarative_enum, default_select_columns, delete_all_returning, #deleted_from_database?, id_in, id_not_in, iid_in, nullable_column?, 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 Organizations::Sharding
Methods included from ResetOnColumnErrors
#reset_on_union_error, #reset_on_unknown_attribute_error
Methods included from Gitlab::SensitiveSerializableHash
Instance Method Details
#refresh! ⇒ Object
36 37 38 39 40 41 42 43 44 |
# File 'app/models/snippet_statistics.rb', line 36 def refresh! return if Gitlab::Database.read_only? update_commit_count update_repository_size update_file_count save! end |
#update_commit_count ⇒ Object
18 19 20 |
# File 'app/models/snippet_statistics.rb', line 18 def update_commit_count self.commit_count = repository.commit_count end |
#update_file_count ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'app/models/snippet_statistics.rb', line 26 def update_file_count count = if snippet.repository_exists? repository.ls_files(snippet.default_branch).size else 0 end self.file_count = count end |
#update_repository_size ⇒ Object
22 23 24 |
# File 'app/models/snippet_statistics.rb', line 22 def update_repository_size self.repository_size = repository.size.megabytes end |