class Admins::ImportCompetitionScoreExcel < BaseImportXlsx
  Data = Struct.new(:competition_team_id, :score)

  def read_each(&block)
    sheet.each_row_streaming(pad_cells: true, offset: 1) do |row|
      data = row.map(&method(:cell_value))[0..1]
      block.call Data.new(*data)
    end
  end

  private

  def check_sheet_valid!
    raise_import_error('请按照模板格式导入') if sheet.row(1).size != 2
  end

  def cell_value(obj)
    obj&.cell_value&.to_s&.strip
  end
end
