Class: Suggestions::OutdateService

Inherits:
Object
  • Object
show all
Defined in:
app/services/suggestions/outdate_service.rb

Instance Method Summary collapse

Instance Method Details

#execute(merge_request) ⇒ Object


5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'app/services/suggestions/outdate_service.rb', line 5

def execute(merge_request)
  # rubocop: disable CodeReuse/ActiveRecord
  suggestions = merge_request.suggestions.active.includes(:note)

  suggestions.find_in_batches(batch_size: 100) do |group|
    outdatable_suggestion_ids = group.select do |suggestion|
      suggestion.outdated?(cached: false)
    end.map(&:id)

    Suggestion.where(id: outdatable_suggestion_ids).update_all(outdated: true)
  end
  # rubocop: enable CodeReuse/ActiveRecord
end