Class: Search::FindLotByBatchId

Inherits:
Search show all
Defined in:
app/models/search/find_lot_by_batch_id.rb

Overview

Used by Gatekeeper to find the lot associated with a batch. Not used nowadays, as QC is no longer performed in house.

Instance Method Summary collapse

Methods included from Uuid::Uuidable

included, #unsaved_uuid!, #uuid

Methods inherited from ApplicationRecord

alias_association, convert_labware_to_receptacle_for, find_by_id_or_name, find_by_id_or_name!

Methods included from Squishify

extended

Instance Method Details

#parent_of_purpose(batch) ⇒ Object



10
11
12
13
14
15
# File 'app/models/search/find_lot_by_batch_id.rb', line 10

def parent_of_purpose(batch)
  input_labware = batch&.input_labware
  return nil if input_labware.empty?

  input_labware.first.ancestors.joins(:purpose).find_by(plate_purposes: { name: 'Tag PCR' })
end

#scope(criteria) ⇒ Object



5
6
7
8
# File 'app/models/search/find_lot_by_batch_id.rb', line 5

def scope(criteria)
  root_asset = parent_of_purpose(Batch.find_by(id: criteria['batch_id']))
  Lot.with_qc_asset(root_asset)
end