Class: V1::MultiPoolResource
- Inherits:
-
JSONAPI::Resource
- Object
- JSONAPI::Resource
- V1::MultiPoolResource
- Defined in:
- app/resources/v1/multi_pool_resource.rb
Overview
Access this resource via the /v1/multi_pools endpoint.
MultiPoolResource provides a JSON:API representation of the MultiPool model. It allows API clients to query, filter, and retrieve multi-pool-related information.
Provides a JSON:API representation of MultiPool and exposes valid request for use by the UI.
Filters: * pipeline * pool_method * pool_barcode
Primary relationships: * multi_pool_positions MultiPoolPositionResource
Constant Summary collapse
- MULTI_POOL_POSITIONS_ATTRIBUTES =
%w[id position pacbio_pool_attributes].freeze
- PACBIO_POOL_ATTRIBUTES =
%w[id volume concentration template_prep_kit_box_barcode insert_size created_at updated_at library_attributes used_aliquots_attributes primary_aliquot_attributes used_volume available_volume].freeze
- ALIQUOT_ATTRIBUTES =
%w[id volume concentration template_prep_kit_box_barcode insert_size tag_id source_id source_type].freeze
Instance Attribute Summary collapse
-
#created_at ⇒ String
readonly
The creation date of the multi_pool in US format via override below.
-
#multi_pool_position_attributes ⇒ Array<Hash>
writeonly
Attributes for creating/updating nested multi_pool_positions.
-
#number_of_pools ⇒ Integer
readonly
A computed number of pools in the multi_pool.
-
#pipeline ⇒ String
The pipeline associated with the multi_pool .e.g.
-
#pool_method ⇒ Integer
The method used for pooling.
Class Method Summary collapse
Instance Method Summary collapse
- #fetchable_fields ⇒ Object
-
#multi_pool_positions_attributes=(multi_pool_positions_parameters) ⇒ Object
We need to override the setter to permit nested attributes for multi_pool_positions and their nested pacbio_pools and their nested used_aliquots and primary_aliquot.
- #publish_messages_on_creation ⇒ Object
- #publish_messages_on_update ⇒ Object
Instance Attribute Details
#created_at ⇒ String (readonly)
Returns the creation date of the multi_pool in US format via override below.
122 |
# File 'app/resources/v1/multi_pool_resource.rb', line 122 attributes :number_of_pools, :created_at, readonly: true |
#multi_pool_position_attributes=(value) ⇒ Array<Hash> (writeonly)
Returns attributes for creating/updating nested multi_pool_positions.
126 |
# File 'app/resources/v1/multi_pool_resource.rb', line 126 attribute :multi_pool_positions_attributes |
#number_of_pools ⇒ Integer (readonly)
Returns a computed number of pools in the multi_pool.
122 |
# File 'app/resources/v1/multi_pool_resource.rb', line 122 attributes :number_of_pools, :created_at, readonly: true |
#pipeline ⇒ String
Returns the pipeline associated with the multi_pool .e.g. “Pacbio” or “Ont”.
116 |
# File 'app/resources/v1/multi_pool_resource.rb', line 116 attributes :pool_method, :pipeline |
#pool_method ⇒ Integer
Returns the method used for pooling.
116 |
# File 'app/resources/v1/multi_pool_resource.rb', line 116 attributes :pool_method, :pipeline |
Class Method Details
.default_sort ⇒ Object
147 148 149 |
# File 'app/resources/v1/multi_pool_resource.rb', line 147 def self.default_sort [{ field: 'created_at', direction: :desc }] end |
Instance Method Details
#fetchable_fields ⇒ Object
188 189 190 |
# File 'app/resources/v1/multi_pool_resource.rb', line 188 def fetchable_fields super - %i[multi_pool_positions_attributes] end |
#multi_pool_positions_attributes=(multi_pool_positions_parameters) ⇒ Object
We need to override the setter to permit nested attributes for multi_pool_positions and their nested pacbio_pools and their nested used_aliquots and primary_aliquot
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 |
# File 'app/resources/v1/multi_pool_resource.rb', line 168 def multi_pool_positions_attributes=(multi_pool_positions_parameters) # rubocop:disable Metrics/MethodLength @model.multi_pool_positions_attributes = multi_pool_positions_parameters.map do |mpp| mpp.permit( *MULTI_POOL_POSITIONS_ATTRIBUTES, :_destroy, pacbio_pool_attributes: [ :_destroy, *PACBIO_POOL_ATTRIBUTES, { used_aliquots_attributes: [ :_destroy, *ALIQUOT_ATTRIBUTES ], primary_aliquot_attributes: [ *ALIQUOT_ATTRIBUTES ] } ] ).to_h.with_indifferent_access end end |
#publish_messages_on_creation ⇒ Object
192 193 194 195 196 197 198 199 200 |
# File 'app/resources/v1/multi_pool_resource.rb', line 192 def # Collect pacbio pools only @model.multi_pool_positions.each do |mpp| next if mpp.pacbio_pool.blank? # Publish volume tracking message for each pacbio pool's primary aliquot Emq::Publisher.publish(mpp.pacbio_pool.primary_aliquot, Pipelines.pacbio, 'volume_tracking') end end |
#publish_messages_on_update ⇒ Object
202 203 204 205 206 207 208 209 210 211 212 213 |
# File 'app/resources/v1/multi_pool_resource.rb', line 202 def @model.multi_pool_positions.each do |mpp| next if mpp.pacbio_pool.blank? # Publish volume tracking message for each pacbio pool's primary aliquot Emq::Publisher.publish(mpp.pacbio_pool.primary_aliquot, Pipelines.pacbio, 'volume_tracking') # Publish messages for sequencing runs associated with the pool # This may not be the most efficient way as a multi pool may be updated without every pool # being changed, but it ensures all runs are up to date Messages.publish(mpp.pacbio_pool.sequencing_runs, Pipelines.pacbio.) end end |