Class: Users::UpdateTodoCountCacheService
- Inherits:
-
BaseService
- Object
- BaseService
- Users::UpdateTodoCountCacheService
- Defined in:
- app/services/users/update_todo_count_cache_service.rb
Constant Summary collapse
- QUERY_BATCH_SIZE =
10
Instance Attribute Summary collapse
-
#user_ids ⇒ Object
readonly
Returns the value of attribute user_ids.
Attributes inherited from BaseService
#current_user, #params, #project
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(user_ids) ⇒ UpdateTodoCountCacheService
constructor
user_ids - An array of User IDs.
Methods included from BaseServiceUtility
#deny_visibility_level, #event_service, #log_error, #log_info, #notification_service, #system_hook_service, #todo_service, #visibility_level
Methods included from Gitlab::Allowable
Constructor Details
#initialize(user_ids) ⇒ UpdateTodoCountCacheService
user_ids - An array of User IDs
10 11 12 |
# File 'app/services/users/update_todo_count_cache_service.rb', line 10 def initialize(user_ids) @user_ids = user_ids end |
Instance Attribute Details
#user_ids ⇒ Object (readonly)
Returns the value of attribute user_ids.
7 8 9 |
# File 'app/services/users/update_todo_count_cache_service.rb', line 7 def user_ids @user_ids end |
Instance Method Details
#execute ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'app/services/users/update_todo_count_cache_service.rb', line 14 def execute user_ids.each_slice(QUERY_BATCH_SIZE) do |user_ids_batch| todo_counts = Todo.for_user(user_ids_batch).count_grouped_by_user_id_and_state user_ids_batch.each do |user_id| update_count_cache(user_id, todo_counts, :done) update_count_cache(user_id, todo_counts, :pending) end end end |