-
Notifications
You must be signed in to change notification settings - Fork 5
Y25-483 - Show Lot information using the v2 API #652
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
cbb9b5b
e5fde1c
b9aa9cc
b2936ed
02665d3
9b89abe
28594a5
007e05d
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 |
|---|---|---|
|
|
@@ -44,7 +44,11 @@ def printer_type | |
| def prefix | ||
| return '' if @lot.qcables.empty? | ||
|
|
||
| @lot.qcables.first.barcode.prefix | ||
| qcable = @lot.qcables.first | ||
|
|
||
| labware_prefix(qcable) || | ||
| barcode_prefix(qcable) || | ||
| '' | ||
| end | ||
|
|
||
| ## | ||
|
|
@@ -89,8 +93,6 @@ def number_pending | |
| pending_qcable_uuids.count | ||
| end | ||
|
|
||
| private | ||
|
|
||
| def state_index(state) | ||
| %w( | ||
| created | ||
|
|
@@ -111,4 +113,31 @@ def sorted_qcables | |
| def state_counts | ||
| @counts ||= sorted_qcables.map { |state, qcables| [state, qcables.count] } | ||
| end | ||
|
|
||
| private | ||
|
|
||
| def labware_prefix(qcable) | ||
| return unless qcable.respond_to?(:labware_barcode) | ||
|
|
||
| human = human_barcode(qcable) | ||
| return unless human | ||
|
|
||
| human[/\A([A-Za-z]+)/, 1] | ||
| end | ||
|
|
||
| def barcode_prefix(qcable) | ||
| return unless qcable.respond_to?(:barcode) | ||
|
|
||
| barcode = qcable.barcode | ||
| return unless barcode.respond_to?(:prefix) | ||
|
|
||
| barcode.prefix | ||
| end | ||
|
|
||
| def human_barcode(qcable) | ||
| lb = qcable.labware_barcode | ||
| return unless lb | ||
|
|
||
| (lb['human_barcode'] || lb[:human_barcode])&.to_s | ||
|
Comment on lines
+138
to
+141
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Optional: I see this is old code, but I think the intent could be better indicated using symbolize_keys? Suggest something like: lb = qcable.labware_barcode&.symbolize_keys
return unless lb
lb[:human_barcode].to_s |
||
| end | ||
| end | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,8 +31,7 @@ def child_type | |
| def barcode | ||
| { | ||
| 'ean13' => @asset.barcode.ean13, | ||
| 'prefix' => @asset.barcode.prefix, | ||
| 'number' => @asset.barcode.number | ||
| 'human_readable' => human_readable | ||
| } | ||
| end | ||
|
|
||
|
|
@@ -61,6 +60,50 @@ def output | |
| } } | ||
| end | ||
|
|
||
| def human_readable | ||
| direct_human_readable || | ||
| direct_human_barcode || | ||
| barcode_fallback || | ||
| '' | ||
| end | ||
|
|
||
| def direct_human_readable | ||
| return unless @asset.respond_to?(:human_readable) | ||
|
|
||
| @asset.human_readable | ||
| end | ||
|
|
||
| def direct_human_barcode | ||
| return unless @asset.respond_to?(:human_barcode) | ||
|
|
||
| @asset.human_barcode | ||
| end | ||
|
|
||
| def barcode_fallback | ||
| return unless @asset.respond_to?(:barcode) | ||
|
|
||
| barcode = @asset.barcode | ||
|
|
||
| object_barcode(barcode) || | ||
| hash_barcode(barcode) | ||
| end | ||
|
|
||
| def object_barcode(barcode) | ||
| return unless barcode.respond_to?(:prefix) && barcode.respond_to?(:number) | ||
|
|
||
| "#{barcode.prefix}#{barcode.number}" | ||
| end | ||
|
|
||
| def hash_barcode(barcode) | ||
| return unless barcode.is_a?(Hash) | ||
|
|
||
| prefix = barcode['prefix'] || barcode[:prefix] | ||
| number = barcode['number'] || barcode[:number] | ||
| return unless prefix || number | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Optional: possibly use |
||
|
|
||
| "#{prefix}#{number}" | ||
| end | ||
|
|
||
| private | ||
|
|
||
| def own_purpose_config | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,15 +18,55 @@ def index | |
| @qcable.stamp_index ? @qcable.stamp_index + 1 : '-' | ||
| end | ||
|
|
||
| def human_readable | ||
| labware_human_barcode || | ||
| barcode_machine || | ||
| barcode_prefix_number || | ||
| '' | ||
| end | ||
|
|
||
| def barcode | ||
| "#{@qcable.barcode.prefix}#{@qcable.barcode.number}" | ||
| human_readable | ||
| end | ||
|
|
||
| def number | ||
| @qcable.barcode.number.to_s | ||
| private | ||
|
|
||
| def labware_human_barcode | ||
| return unless @qcable.respond_to?(:labware_barcode) | ||
|
|
||
| lb = @qcable.labware_barcode | ||
| return unless lb.is_a?(Hash) | ||
|
|
||
| (lb['human_barcode'] || lb[:human_barcode])&.to_s | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Optional: possibly use symbolize_keys here too |
||
| end | ||
|
|
||
| delegate :uuid, to: :@qcable | ||
| def barcode_machine | ||
| return unless @qcable.respond_to?(:barcode) | ||
|
|
||
| bc = @qcable.barcode | ||
|
|
||
| if bc.is_a?(Hash) | ||
| machine = bc['machine'] || bc[:machine] | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Optional: possibly use symbolize_keys here too |
||
| machine&.to_s | ||
| elsif bc.respond_to?(:machine) | ||
| bc.machine&.to_s | ||
| end | ||
| end | ||
|
|
||
| def barcode_prefix_number | ||
| return unless @qcable.respond_to?(:barcode) | ||
|
|
||
| bc = @qcable.barcode | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Optional: possibly use symbolize_keys here too |
||
|
|
||
| if bc.is_a?(Hash) | ||
| prefix = bc['prefix'] || bc[:prefix] | ||
| number = bc['number'] || bc[:number] | ||
| "#{prefix}#{number}" | ||
| elsif bc.respond_to?(:prefix) && bc.respond_to?(:number) | ||
| "#{bc.prefix}#{bc.number}" | ||
| end | ||
| end | ||
|
|
||
| delegate :uuid, to: :@qcable | ||
| alias id uuid | ||
| end | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| <tr id='<%= state %>_plate_<%= child.index %>'> | ||
| <td class='plate_index'><%= child.index %></td> | ||
| <td class='plate_barcode'><%= child.barcode %></td> | ||
| <td><input type='checkbox' id='selected[<%= child.id %>]' name='numbers[<%= child.number %>]' value='<%= child.number %>'/></td> | ||
| <td class='plate_barcode'><%= child.human_readable %></td> | ||
| <td><input type='checkbox' id='selected[<%= child.id %>]' name='barcodes[<%= child.human_readable %>]' value='<%= child.human_readable %>'/></td> | ||
| </tr> |
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.
Nitpick: could this be on one line?