Class: CleanupRemovedParallels

Inherits:
CleanupRemovedRecords show all
Includes:
Interpipe::Interactor
Defined in:
app/interactors/cleanup_removed_parallels.rb

Instance Method Summary collapse

Methods included from Interpipe::Interactor

included, #initialize, #setup

Methods inherited from CleanupRemovedRecords

#cleanup_records

Instance Method Details

#perform(parallels:, faculty_semester:, **options) ⇒ Object


7
8
9
10
11
12
13
14
15
16
17
# File 'app/interactors/cleanup_removed_parallels.rb', line 7

def perform(parallels: , faculty_semester: , **options)
  @parallels = parallels
  @options = options
  stored_parallel_ids = Parallel.where(
    semester: faculty_semester.code,
    faculty: faculty_semester.faculty,
    deleted_at: nil
  ).select_map(:id)
  missing_ids = cleanup_records(parallels, stored_parallel_ids, Parallel)
  TimetableSlot.where(parallel_id: missing_ids, deleted_at: nil).update(deleted_at: Sequel.function(:NOW))
end

#resultsObject


19
20
21
# File 'app/interactors/cleanup_removed_parallels.rb', line 19

def results
  { parallels: @parallels }.merge(@options)
end