-
Notifications
You must be signed in to change notification settings - Fork 34
Y26 031 labware location report by retention instructions #5637
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
a5b5a47
e446636
99653c3
67bc87f
fc408a1
31159ad
0b1e94f
77a9e04
a2a9912
7e4e26f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,7 @@ class LocationReport < ApplicationRecord | |
| serialize :faculty_sponsor_ids, type: Array, coder: YAML | ||
| serialize :plate_purpose_ids, type: Array, coder: YAML | ||
| serialize :barcodes, type: Array, coder: YAML | ||
| serialize :retention_instructions, type: Array, coder: YAML | ||
| self.per_page = 20 | ||
| enum :report_type, { type_selection: 0, type_labwhere: 1 } | ||
|
|
||
|
|
@@ -49,7 +50,7 @@ def check_location_barcode | |
| end | ||
|
|
||
| def check_any_select_field_present | ||
| attr_list = %i[faculty_sponsor_ids study_id start_date end_date plate_purpose_ids barcodes] | ||
| attr_list = %i[faculty_sponsor_ids study_id start_date end_date plate_purpose_ids barcodes retention_instructions] | ||
| if attr_list.all? { |attr| send(attr).blank? } | ||
| errors.add(:base, I18n.t('location_reports.errors.no_selection_fields_filled')) | ||
| end | ||
|
|
@@ -119,7 +120,6 @@ def generate_report_rows # rubocop:todo Metrics/MethodLength | |
| end | ||
|
|
||
| yield column_headers | ||
|
|
||
| labware_list.each do |cur_labware| | ||
| if cur_labware.studies.present? | ||
| cur_labware.studies.each { |cur_study| yield(generate_report_row(cur_labware, cur_study)) } | ||
|
|
@@ -176,14 +176,30 @@ def generate_study_cols_for_row(cur_study) | |
| end | ||
|
|
||
| def search_for_labware_by_selection | ||
| params = { faculty_sponsor_ids:, study_id:, start_date:, end_date:, plate_purpose_ids:, barcodes: } | ||
| params = { faculty_sponsor_ids:, study_id:, start_date:, end_date:, plate_purpose_ids:, barcodes:, | ||
| retention_instructions: } | ||
| validate_result_size(params) | ||
|
|
||
| # Only plates and tubes are currently supported by this report | ||
| labwares = Labware.search_for_labware(params).filter { |labware| labware.is_a?(Plate) || labware.is_a?(Tube) } | ||
|
|
||
| filter_labware_by_retention_instructions(labwares) | ||
|
Comment on lines
178
to
+186
|
||
| end | ||
|
|
||
| def filter_labware_by_retention_instructions(labwares) | ||
| return labwares if retention_instructions.blank? | ||
|
|
||
| labwares.select do |lw| | ||
| retention_instructions.include?(normalize_retention_instruction(lw.retention_instructions)) | ||
| end | ||
| end | ||
|
|
||
| def validate_result_size(params) | ||
| count = Labware.search_for_count_of_labware(params) | ||
| if count > configatron.fetch(:location_reports_fetch_count_max, 25000) | ||
| errors.add(:base, I18n.t('location_reports.errors.too_many_labwares_found', count:)) | ||
| return [] | ||
| [] | ||
| end | ||
| # Only plates and tubes are currently supported by this report | ||
| Labware.search_for_labware(params).filter { |labware| labware.is_a?(Plate) || labware.is_a?(Tube) } | ||
| end | ||
|
Comment on lines
+197
to
203
|
||
|
|
||
| def search_for_labware_by_labwhere_locn_bc | ||
|
|
@@ -208,5 +224,9 @@ def get_labwares_per_location(curr_locn_bc) | |
| curr_locn_children = LabWhereClient::Location.children(curr_locn_bc) | ||
| curr_locn_children.each { |curr_locn| get_labwares_per_location(curr_locn.barcode) } if curr_locn_children.present? | ||
| end | ||
|
|
||
| def normalize_retention_instruction(value) | ||
| value.to_s.parameterize(separator: '_') | ||
| end | ||
| end | ||
| # rubocop:enable Metrics/ClassLength | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| # frozen_string_literal: true | ||
| class AddRetentionInstructionsToLocationReports < ActiveRecord::Migration[7.2] | ||
| def change | ||
| add_column :location_reports, :retention_instructions, :text | ||
| end | ||
| end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
location_report_paramspermits:barcodesand:barcodes_texttwice. This duplication is redundant and can confuse future edits; remove the duplicates so each permitted key appears only once.