<commit_before># frozen_string_literal: true

#
# Takes a list of source plates and validates that all plates
# are older than the lifespan defined by their plate purpose
class Verification::OutdatedLabware::Base < Verification::Base
  validates_with Verification::Validator::OutdatedPlatesScanned

  attr_accessor :plate_barcodes_to_destroy, :messages

  self.partial_name = 'outdated_labware'

  def scanned_values
    [@attributes[:scanned_values]].flatten.map { |s| s.split(/\s/).reject(&:blank?) }.flatten
  end

  def search_resource
    api.search.find(Settings.search_find_assets_by_barcode)
  end

  def plates_from_barcodes(barcodes)
    plates = Sequencescape::Api::V2::Labware.where(barcode: barcodes)
    plate_hash = plates.index_by { |plate| plate.labware_barcode['machine_barcode'] }

    barcodes.to_h { |barcode| [barcode, plate_hash[barcode]] }
  end

  def validate_and_create_audits?(params)
    return false unless valid?

    params[:source_plates] = scanned_values.flatten.join(' ')
    super(params)
  end
end
<commit_msg>Remove search_resource as is no longer used - remove these attr_accessors - if they are used, I can't see where<commit_after># frozen_string_literal: true

#
# Takes a list of source plates and validates that all plates
# are older than the lifespan defined by their plate purpose
class Verification::OutdatedLabware::Base < Verification::Base
  validates_with Verification::Validator::OutdatedPlatesScanned

  self.partial_name = 'outdated_labware'

  def scanned_values
    [@attributes[:scanned_values]].flatten.map { |s| s.split(/\s/).reject(&:blank?) }.flatten
  end

  def plates_from_barcodes(barcodes)
    plates = Sequencescape::Api::V2::Labware.where(barcode: barcodes)
    plate_hash = plates.index_by { |plate| plate.labware_barcode['machine_barcode'] }

    barcodes.to_h { |barcode| [barcode, plate_hash[barcode]] }
  end

  def validate_and_create_audits?(params)
    return false unless valid?

    params[:source_plates] = scanned_values.flatten.join(' ')
    super(params)
  end
end

{'fraction_non_alphanumeric': 0.1015625, 'fraction_numerical': 0.0009765625, 'mean_word_length': 5.209090909090909, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2228551', 'n_tokens_mistral': 681, 'n_tokens_neox': 648, 'n_words': 150}