class Maintenance::Attendance::EdfiJob
  include Sidekiq::Worker

  def perform(job)
    school = School.find(3188)
    school_year = school.school_years.find(217261)
    attendances = school_year.attendances

    case job.to_sym
    when :virtual
      attendances = attendances
        .where(type_id: [4948, 4835])
        .or(attendances.where(type_2_id: [4948, 4835]))
      attendances.update_all(present: 1, absent: 0)
    when :present
      attendances = attendances
        .where(type_id: 0, type_2_id: 0)
        .where(is_present: 1)

      attendances.update_all(type_id: 4834)
    end
  end
end
