Skip to content

Commit

Permalink
Merge pull request #2181 from sanger/y24-502-fix-incorrect-warning-ac…
Browse files Browse the repository at this point in the history
…tive-submission-requests

Y24 502 fix incorrect warning active submission requests
  • Loading branch information
seenanair authored Jan 22, 2025
2 parents 5430f77 + 5adfd97 commit 050bc86
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
8 changes: 5 additions & 3 deletions app/models/validators/in_progress_validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ module Validators
# Displays a warning if the requests on the plate have already been completed
class InProgressValidator < ActiveModel::Validator
def validate(presenter)
return true unless presenter.labware.any_complete_requests?
return true unless presenter.labware.any_non_create_asset_requests_completed?

first_request = presenter.labware.active_non_create_asset_requests.first

return true if first_request.nil?
presenter.errors.add(
:submission,
'(active) is not present for this labware. ' \
'Any further work conducted from this plate may run into issues at the end of the pipeline.'
"Requests of type #{first_request.request_type.name} have already been down the pipeline and were completed."
)
end
end
Expand Down
10 changes: 10 additions & 0 deletions app/sequencescape/sequencescape/api/v2/shared/has_requests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,16 @@ def any_complete_requests?
active_requests.any?(&:passed?)
end

def any_non_create_asset_requests_completed?
# Filter out CreateAssetRequests which will be associated for an input plate and completed by the time we get here
# and not relevant to this check
active_non_create_asset_requests.filter_map(&:passed?).any?
end

def active_non_create_asset_requests
active_requests.reject { |r| r.request_type_key == 'create_asset' }
end

def pcr_cycles
active_requests.map(&:pcr_cycles).uniq
end
Expand Down
6 changes: 2 additions & 4 deletions spec/features/viewing_a_minimal_plate_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@
scenario 'there is a warning' do
fill_in_swipecard_and_barcode user_swipecard, plate_barcode
expect(find('.asset-warnings')).to have_content(
'Submission (active) is not present for this labware. ' \
'Any further work conducted from this plate may run into issues at the end of the pipeline.'
'Submission Requests of type Limber WGS have already been down the pipeline and were completed.'
)
end
end
Expand Down Expand Up @@ -105,8 +104,7 @@
scenario 'there is a warning' do
fill_in_swipecard_and_barcode user_swipecard, plate_barcode
expect(find('.asset-warnings')).to have_content(
'Submission (active) is not present for this labware. ' \
'Any further work conducted from this plate may run into issues at the end of the pipeline.'
'Submission Requests of type Limber WGS have already been down the pipeline and were completed.'
)
end
end
Expand Down
3 changes: 1 addition & 2 deletions spec/features/viewing_a_plate_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,7 @@
scenario 'there is a warning' do
fill_in_swipecard_and_barcode user_swipecard, plate_barcode
expect(find('.asset-warnings')).to have_content(
'Submission (active) is not present for this labware. ' \
'Any further work conducted from this plate may run into issues at the end of the pipeline.'
'Submission Requests of type Limber WGS have already been down the pipeline and were completed.'
)
end
end
Expand Down

0 comments on commit 050bc86

Please sign in to comment.