Class: Gitlab::GithubImport::ObjectCounter
- Inherits:
-
Object
- Object
- Gitlab::GithubImport::ObjectCounter
- Defined in:
- lib/gitlab/github_import/object_counter.rb
Constant Summary collapse
- OPERATIONS =
%w[fetched imported].freeze
- PROJECT_COUNTER_LIST_KEY =
'github-importer/object-counters-list/%{project}/%{operation}'
- PROJECT_COUNTER_KEY =
'github-importer/object-counter/%{project}/%{operation}/%{object_type}'
- GLOBAL_COUNTER_KEY =
'github_importer_%{operation}_%{object_type}'
- GLOBAL_COUNTER_DESCRIPTION =
'The number of %{operation} Github %{object_type}'
- CACHING =
Gitlab::Cache::Import::Caching
Class Method Summary collapse
-
.increment(project, object_type, operation, value: 1) ⇒ Object
Increments the project and the global counters if the given value is >= 1.
- .summary(project) ⇒ Object
Class Method Details
.increment(project, object_type, operation, value: 1) ⇒ Object
Increments the project and the global counters if the given value is >= 1
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/gitlab/github_import/object_counter.rb', line 18 def increment(project, object_type, operation, value: 1) integer = value.to_i return if integer <= 0 validate_operation!(operation) increment_project_counter(project, object_type, operation, integer) increment_global_counter(object_type, operation, integer) project.import_state&.expire_etag_cache end |
.summary(project) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/gitlab/github_import/object_counter.rb', line 31 def summary(project) OPERATIONS.each_with_object({}) do |operation, result| result[operation] = {} CACHING .values_from_set(counter_list_key(project, operation)) .sort .each do |counter| object_type = counter.split('/').last result[operation][object_type] = CACHING.read_integer(counter) end end end |