Class: ConvertCourseEvents

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

Instance Method Summary collapse

Methods included from Interpipe::Interactor

included, #initialize, #setup

Instance Method Details

#convert_event(course_event) ⇒ Object


16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'app/interactors/convert_course_events.rb', line 16

def convert_event(course_event)
  Event.new(
    starts_at: course_event.start_date,
    ends_at: course_event.end_date,
    capacity: course_event.capacity,
    event_type: 'course_event',
    absolute_sequence_number: 1,
    source_type: 'course_event',
    source_id: course_event.link.link_id,
    semester: @faculty_semester.code,
    faculty: @faculty_semester.faculty,
    room_id: course_event.room.try(:link_id),
    teacher_ids: [course_event.creator.try(:link_id)].compact,
    name: course_event.name.try(:translations),
    note: course_event.note.try(:translations),
    course_id: course_event.course.try(:link_id)
  )
end

#perform(course_events:, faculty_semester:) ⇒ Object


6
7
8
9
10
# File 'app/interactors/convert_course_events.rb', line 6

def perform(course_events:, faculty_semester:)
  @course_events = course_events
  @faculty_semester = faculty_semester
  @events = course_events.map { |event| convert_event(event) }
end

#resultsObject


12
13
14
# File 'app/interactors/convert_course_events.rb', line 12

def results
  { events: @events, course_events: @course_events }
end