Class: FetchParallelStudents

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

Instance Method Summary collapse

Methods included from Interpipe::Interactor

included, #initialize

Instance Method Details

#fetch_students(parallel, client) ⇒ Object


24
25
26
# File 'app/interactors/fetch_parallel_students.rb', line 24

def fetch_students(parallel, client)
  client.parallels.find(parallel.id).students.limit(100).order_by('id')
end

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


12
13
14
15
16
17
18
# File 'app/interactors/fetch_parallel_students.rb', line 12

def perform(parallels:, faculty_semester:, **options)
  client = kosapi_client(faculty_semester)
  students = parallels.map do |parallel|
    [parallel, fetch_students(parallel, client)]
  end
  @students = Hash[students]
end

#resultsObject


20
21
22
# File 'app/interactors/fetch_parallel_students.rb', line 20

def results
  {students: @students}
end

#setup(client: nil) ⇒ Object


8
9
10
# File 'app/interactors/fetch_parallel_students.rb', line 8

def setup(client: nil)
  @forced_client = client
end