Class: LabEvent

Inherits:
ApplicationRecord show all
Includes:
ActsAsDescriptable
Defined in:
app/models/lab_event.rb

Overview

Lab events are created as part of the traditional Sequencescape based pipelines they track the information supplied in each step, mostly in the form of descriptors: key value pairs. They can be associated with individual requests, or the batch as a whole. The information is mainly displayed on the batch summary screen, but also acts as a source of information for the FlowcellIO message

Constant Summary collapse

CHIP_BARCODE_STEPS =
['Cluster generation', 'Add flowcell chip barcode', 'Loading'].freeze

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ActsAsDescriptable

#add_descriptor, #descriptor_hash, #descriptor_value, #descriptors, included

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

Class Method Details

.find_batch_id_by_barcode(barcode) ⇒ Object



27
28
29
30
# File 'app/models/lab_event.rb', line 27

def self.find_batch_id_by_barcode(barcode)
  batch_ids = with_flowcell_barcode(barcode).distinct.pluck(:batch_id)
  batch_ids.first if batch_ids.one?
end

Instance Method Details

#add_new_descriptor(name, value) ⇒ Object



36
37
38
# File 'app/models/lab_event.rb', line 36

def add_new_descriptor(name, value)
  add_descriptor Descriptor.new(name:, value:)
end

#descriptor_value_for(name) ⇒ Object



32
33
34
# File 'app/models/lab_event.rb', line 32

def descriptor_value_for(name)
  descriptors.detect { |desc| desc.name.casecmp?(name.to_s) }&.value
end

#generate_broadcast_eventObject



40
41
42
# File 'app/models/lab_event.rb', line 40

def generate_broadcast_event
  BroadcastEvent::LabEvent.create!(seed: self, user: user)
end