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

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


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

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


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

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

#descriptor_value_for(name) ⇒ Object


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

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

#generate_broadcast_eventObject


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

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