Class: AssignPeople

Inherits:
Object
  • Object
show all
Includes:
Interpipe::Interactor
Defined in:
app/interactors/assign_people.rb

Instance Method Summary collapse

Methods included from Interpipe::Interactor

included, #initialize, #setup

Instance Method Details

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


8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/interactors/assign_people.rb', line 8

def perform(faculty_semester:, **options)
  exceptions = TeacherChangeScheduleException
    .where(faculty: faculty_semester.faculty, semester: faculty_semester.code).all

  exceptional_events = Event.where(:applied_schedule_exception_ids.pg_array.overlaps(
      Sequel.pg_array(exceptions.map(&:id), :bigint)))

  exceptional_event_ids = exceptional_events.map do |event|
    exceptions.each do |exception|
      exception.apply_people_assign(event) if exception.affects?(event)
    end
    event.id
  end

  assign_teachers! faculty_semester, exceptional_event_ids
  assign_students! faculty_semester
end