-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Revert "DPL-960- Bioscan input plate state changes""
- Loading branch information
1 parent
7794cff
commit a7031ff
Showing
5 changed files
with
103 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# frozen_string_literal: true | ||
|
||
# Input Plate purposes are the initial stock plates passing into | ||
# external piplines. They have special behaviour governing their state. | ||
# This essentially makes sure that all non-empty wells on a plate have requests | ||
# out of them. This is intended to ensure that submissions have been | ||
# correctly built before a plate has processed. | ||
# | ||
# - Input plates are progressed when all sample containing wells have requests out of them | ||
# | ||
# This version of the input class sets the state as started rather than passed. | ||
class PlatePurpose::InputStarted < PlatePurpose::Input | ||
self.state_changer = StateChanger::InputStartedPlate | ||
|
||
UNREADY_STATE = 'pending' | ||
PREP_STATE = 'started' | ||
READY_STATE = 'passed' | ||
|
||
private | ||
|
||
# The state of the plate is determined by the state of the wells | ||
# In this version we add an extra state PREP_STATE | ||
def calculate_state_of_plate(wells_states) | ||
unique_states = wells_states.uniq | ||
return UNREADY_STATE if unique_states.include?(:unready) | ||
|
||
case unique_states.sort | ||
when ['failed'], %w[cancelled failed] | ||
'failed' | ||
when ['cancelled'] | ||
'cancelled' | ||
else | ||
unique_states.all?('pending') ? PREP_STATE : READY_STATE | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# frozen_string_literal: true | ||
|
||
module StateChanger | ||
# This adds an additional started state to input plates, which is used | ||
# by the input_started plate purpose. | ||
class InputStartedPlate < InputPlate | ||
# Target state of labware to state of associated requests. | ||
# All other transitions will be ignored. | ||
self.map_target_state_to_associated_request_state = { 'failed' => 'failed', 'passed' => 'started' } | ||
|
||
private | ||
|
||
def associated_requests | ||
receptacles.flat_map(&:requests_as_source) | ||
end | ||
|
||
def _receptacles | ||
labware.wells.includes(:requests_as_source) | ||
end | ||
|
||
def transfer_requests | ||
# We don't want to update any transfer requests | ||
[] | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters