Class: BroadcastEvent::QcAssay
Overview
Serializes lab events for the event warehouse
Constant Summary
EVENT_JSON_ROOT, UNKNOWN_USER_IDENTIFIER
Class Method Summary
collapse
Instance Method Summary
collapse
#json_root, #metadata, #routing_key, set_event_type, #subjects, #user_identifier
#has_subject, #has_subjects, #seed_class, #seed_subject, #subject_associations
#has_metadata, #metadata_finders
#render_class
included, #unsaved_uuid!, #uuid
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
.generate_events(qc_assay) ⇒ Object
7
8
9
10
11
12
13
14
15
|
# File 'app/models/broadcast_event/qc_assay.rb', line 7
def self.generate_events(qc_assay)
qc_assay
.qc_results
.distinct
.pluck(:assay_type, :assay_version)
.map { |assay_type, assay_version| create!(seed: qc_assay, properties: { assay_type:, assay_version: }) }
end
|
Instance Method Details
#assay_type ⇒ Object
29
30
31
|
# File 'app/models/broadcast_event/qc_assay.rb', line 29
def assay_type
properties.fetch(:assay_type, template_result.assay_type)
end
|
#assay_version ⇒ Object
33
34
35
|
# File 'app/models/broadcast_event/qc_assay.rb', line 33
def assay_version
properties.fetch(:assay_version, template_result.assay_version)
end
|
#assayed_labware ⇒ Object
53
54
55
|
# File 'app/models/broadcast_event/qc_assay.rb', line 53
def assayed_labware
qc_results.flat_map { |qcr| qcr.asset.labware }.uniq
end
|
#event_type ⇒ Object
25
26
27
|
# File 'app/models/broadcast_event/qc_assay.rb', line 25
def event_type
"quant_#{assay_type.downcase.gsub(/[^\w]+/, '_')}"
end
|
#qc_results ⇒ Object
41
42
43
|
# File 'app/models/broadcast_event/qc_assay.rb', line 41
def qc_results
@qc_results || seed.qc_results.where(properties).includes(%i[asset samples studies])
end
|
#samples ⇒ Object
45
46
47
|
# File 'app/models/broadcast_event/qc_assay.rb', line 45
def samples
qc_results.flat_map(&:samples).uniq
end
|
#stock_plates ⇒ Object
57
58
59
|
# File 'app/models/broadcast_event/qc_assay.rb', line 57
def stock_plates
assayed_labware.flat_map(&:original_stock_plates).compact.uniq
end
|
#studies ⇒ Object
49
50
51
|
# File 'app/models/broadcast_event/qc_assay.rb', line 49
def studies
qc_results.flat_map(&:studies).uniq
end
|
#template_result ⇒ Object
37
38
39
|
# File 'app/models/broadcast_event/qc_assay.rb', line 37
def template_result
seed.qc_results.first
end
|