class EdFi::Indiana::DissociativeIdJob
  include Sidekiq::Worker
  include Sidekiq::Status::Worker

  def perform
    ed_fi_ids.each do |ed_fi_id|
      dir = "#{ed_fi_id.school_year.school.indiana_environment_service}::CalendarDatesService"
      dir.constantize
        .new(ed_fi_id.school_year_id)
        .delete(ed_fi_id)
    end
  end

  private
    # Make this query dynamic per endpoint
    def ed_fi_ids
      EdFi::Id
        .left_joins(:school_day)
        .preload(school_year: :school)
        .where(SchoolDays: { SchoolDaysID: nil })
        .where(endpoint: :calendardates)
    end
end
