Class: Namespaces::UpdateDenormalizedDescendantsService
- Inherits:
-
Object
- Object
- Namespaces::UpdateDenormalizedDescendantsService
- Includes:
- Gitlab::Utils::StrongMemoize
- Defined in:
- app/services/namespaces/update_denormalized_descendants_service.rb
Constant Summary collapse
- NAMESPACE_TYPE_MAPPING =
{ 'Project' => :project_namespace_ids, 'Group' => :group_ids }.freeze
Instance Method Summary collapse
- #execute ⇒ Object
- #execute_with_optimistic_locking ⇒ Object
-
#initialize(namespace_id:) ⇒ UpdateDenormalizedDescendantsService
constructor
A new instance of UpdateDenormalizedDescendantsService.
Constructor Details
#initialize(namespace_id:) ⇒ UpdateDenormalizedDescendantsService
Returns a new instance of UpdateDenormalizedDescendantsService.
12 13 14 |
# File 'app/services/namespaces/update_denormalized_descendants_service.rb', line 12 def initialize(namespace_id:) @namespace_id = namespace_id end |
Instance Method Details
#execute ⇒ Object
16 17 18 |
# File 'app/services/namespaces/update_denormalized_descendants_service.rb', line 16 def execute execute_with_optimistic_locking end |
#execute_with_optimistic_locking ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'app/services/namespaces/update_denormalized_descendants_service.rb', line 20 def execute_with_optimistic_locking namespace = Namespace.primary_key_in(namespace_id).first descendants = Namespaces::Descendants.primary_key_in(namespace_id).first return if descendants.nil? if namespace begin update_namespace_descendants_with_low_lock_timeout(namespace, descendants) rescue ActiveRecord::LockWaitTimeout return :not_updated_due_to_lock_timeout end descendants.reset return :not_updated_due_to_optimistic_lock if descendants.outdated_at else descendants.destroy end :processed end |