Class: Search::FindTubes
- Inherits:
-
Search
- Object
- ActiveRecord::Base
- ApplicationRecord
- Search
- Search::FindTubes
- Defined in:
- app/models/search/find_tubes.rb
Instance Method Summary collapse
-
#scope(user_criteria) ⇒ Object
rubocop:todo Metrics/AbcSize, Metrics/MethodLength.
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
Instance Method Details
#scope(user_criteria) ⇒ Object
rubocop:todo Metrics/AbcSize, Metrics/MethodLength
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'app/models/search/find_tubes.rb', line 4 def scope(user_criteria) # rubocop:todo Metrics/AbcSize, Metrics/MethodLength criteria = default_parameters.stringify_keys.merge(user_criteria) purpose_ids = if criteria['tube_purpose_uuids'] Uuid.where(resource_type: 'Purpose', external_id: criteria['tube_purpose_uuids']).pluck(:resource_id) else criteria['tube_purpose_ids'] end Tube .with_purpose(purpose_ids) .include_labware_with_children(criteria['include_used']) .includes(:transfer_requests_as_target, aliquots: Io::Aliquot::PRELOADS) .page(criteria['page']) .limit(criteria['limit']) .order(id: :desc) end |