Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
131 commits
Select commit Hold shift + click to select a range
57c1421
docs: initial diagram
StephenHulme Oct 27, 2025
e371f3f
docs: update diagram
StephenHulme Oct 28, 2025
6ce96cf
docs: only show call links
StephenHulme Oct 28, 2025
77d88d9
docs: add accessioning users
StephenHulme Oct 28, 2025
9d59016
docs: update master diagram
StephenHulme Oct 29, 2025
002d797
docs: fix confusing diagram caused by reverse arrow
StephenHulme Oct 29, 2025
04e2914
docs: update overview diagram title
StephenHulme Oct 30, 2025
5ad395f
docs: adjust display of validation failed arrow
StephenHulme Oct 30, 2025
6fc67ef
Update stocks? method to return true for library assets.
dasunpubudumal Dec 23, 2025
6a3cbd1
feat: Add and update SampleManifest specs to verify stocks behavior f…
dasunpubudumal Dec 23, 2025
0e2775d
feat: Add labware_type method to determine asset type for library res…
dasunpubudumal Dec 23, 2025
5903415
feat: Update stock resource registration for library assets and add s…
dasunpubudumal Dec 23, 2025
be720c8
feat: Update stock receptacles registration to set subject type for l…
dasunpubudumal Dec 24, 2025
1237d5e
feat: Add subject_type method for library tube and multiplexed librar…
dasunpubudumal Dec 24, 2025
e25dcb9
feat: Update lab_event_spec to use 'library_tube' as subject type for…
dasunpubudumal Dec 24, 2025
6cbf223
feat: Add generate method to create plates and update sample manifest…
dasunpubudumal Jan 2, 2026
56a1ef7
feat: Refactor process method to include item processing and subject …
dasunpubudumal Jan 5, 2026
9a43826
feat: Simplify process_item method by removing json parameter and adj…
dasunpubudumal Jan 5, 2026
1ae5218
Fix rubocop
dasunpubudumal Jan 5, 2026
e32f0ac
feat: Remove unused json parameter from process_item method in queue_…
dasunpubudumal Jan 5, 2026
80893c8
feat: Update process_item method to handle item target type and adjus…
dasunpubudumal Jan 5, 2026
e3d972b
Merge remote-tracking branch 'origin/develop' into 5382-y25-697---as-…
dasunpubudumal Jan 9, 2026
6681584
Merge branch 'develop' into 5382-y25-697---as-a-developer-ben-i-would…
dasunpubudumal Jan 12, 2026
f351497
feat: Enhance message processing for receptacle targets and set labwa…
dasunpubudumal Jan 12, 2026
4a284e5
feat: Refactor template and resend methods for consistency and clarity
dasunpubudumal Jan 12, 2026
0076550
feat: Update labware type assignment for library plates in message pr…
dasunpubudumal Jan 12, 2026
c73aeb4
Merge remote-tracking branch 'origin/5382-y25-697---as-a-developer-be…
dasunpubudumal Jan 16, 2026
159551c
feat:adding logs to troubleshoot
dasunpubudumal Jan 16, 2026
2f266a4
test: move sample schema xml validation to rspec test
StephenHulme Jan 16, 2026
250e018
fix: remove y25_286 feature flag
StephenHulme Jan 15, 2026
a2806da
refactor: remove references to Accessionable::Sample
StephenHulme Jan 15, 2026
727c84f
refactor: remove references to accession_local_key and contact_user
StephenHulme Jan 15, 2026
9419568
test: remove FakeAccessionService and references
StephenHulme Jan 15, 2026
430b09e
test: replace feature test with spec/models/accessionable/study_spec.rb
StephenHulme Jan 16, 2026
8a97447
test: remove outdated array express test
StephenHulme Jan 16, 2026
4683142
Merge remote-tracking branch 'origin/develop' into y25-544-and-697
dasunpubudumal Jan 19, 2026
ee0ef0e
Merge branch 'develop' into 5382-y25-697---as-a-developer-ben-i-would…
dasunpubudumal Jan 19, 2026
053db5b
Merge remote-tracking branch 'origin/y25-544-and-697' into 5382-y25-6…
dasunpubudumal Jan 19, 2026
673152f
Merge remote-tracking branch 'origin/develop' into 5382-y25-697---as-…
dasunpubudumal Jan 19, 2026
d94bbaf
Refactor MessengerTest to improve stubbing and add tests for process_…
dasunpubudumal Jan 19, 2026
2897a8f
test: replace study cucumber test with feature test
StephenHulme Jan 21, 2026
2069720
test: replace study dac and policy cucumber test with feature test
StephenHulme Jan 21, 2026
f67ae1f
Merge branch 'develop' into y25-709-remove-obsolete-accessioning-code
StephenHulme Jan 21, 2026
f4ef20c
style: update rubocop todo
StephenHulme Jan 21, 2026
46597ff
Merge branch 'develop' into y25-709-remove-obsolete-accessioning-code
StephenHulme Jan 23, 2026
b90151f
Merge branch 'develop' into y25-709-remove-obsolete-accessioning-code
StephenHulme Jan 23, 2026
f2dfd6b
Merge branch 'develop' into 5382-y25-697---as-a-developer-ben-i-would…
dasunpubudumal Jan 26, 2026
e7cf862
Merge remote-tracking branch 'origin/develop' into 5382-y25-697---as-…
dasunpubudumal Jan 26, 2026
3b72018
Fix indentation for update_subject_type_for_library_receptacles! call…
dasunpubudumal Jan 26, 2026
2a92d62
Merge remote-tracking branch 'origin/5382-y25-697---as-a-developer-be…
dasunpubudumal Jan 26, 2026
10dd910
Merge branch 'develop' into y25-709-remove-obsolete-accessioning-code
StephenHulme Jan 27, 2026
4658946
Merge branch 'develop' into y25-708-update-accessioning-diagram
StephenHulme Jan 28, 2026
6f32fdb
Merge branch 'y25-709-remove-obsolete-accessioning-code' into y25-708…
StephenHulme Jan 28, 2026
7bf0bd8
doc: remove some known removed components
StephenHulme Jan 28, 2026
45b917c
doc: update generate accession number for a single sample
StephenHulme Jan 28, 2026
46c6e8d
doc: update sample manifest and accession all samples
StephenHulme Jan 28, 2026
f13e13c
doc: more cleanup
StephenHulme Jan 29, 2026
6f10125
Merge branch 'develop' into 5382-y25-697---as-a-developer-ben-i-would…
dasunpubudumal Jan 30, 2026
ffe65b2
Remove unnecessary files
dasunpubudumal Feb 2, 2026
60182a0
Merge remote-tracking branch 'origin/develop' into 5382-y25-697---as-…
dasunpubudumal Feb 2, 2026
91641ac
refactor: simplify stock resource registration and update subject types
dasunpubudumal Feb 2, 2026
414d488
refactor: update stock resource registration logic and improve upload…
dasunpubudumal Feb 2, 2026
e2705d3
Merge branch 'develop' into y25-709-remove-obsolete-accessioning-code
StephenHulme Feb 4, 2026
32285de
fix: remove obsolete redirect to the accession-statuses tab
StephenHulme Feb 4, 2026
eada982
Merge branch 'develop' into y25-709-remove-obsolete-accessioning-code
StephenHulme Feb 4, 2026
404f06e
refactor: remove unused AccessionService::UnsuitableService
StephenHulme Feb 4, 2026
860dd62
Merge branch 'develop' into y25-709-remove-obsolete-accessioning-code
StephenHulme Feb 5, 2026
b6ce46d
Merge remote-tracking branch 'origin/develop' into y25-697-send-all-l…
dasunpubudumal Feb 6, 2026
6a22cc6
test: invoke uploader run method in uploader_spec
dasunpubudumal Feb 6, 2026
e919ac1
Merge remote-tracking branch 'origin/develop' into y25-697-send-all-l…
dasunpubudumal Feb 6, 2026
74e63d3
Merge branch 'develop' into y25-709-remove-obsolete-accessioning-code
StephenHulme Feb 6, 2026
c0ecbc3
style: lint
StephenHulme Feb 6, 2026
90e3a01
style: update rubocop todo
StephenHulme Feb 6, 2026
d17b373
Merge branch 'y25-709-remove-obsolete-accessioning-code' into y25-708…
StephenHulme Feb 6, 2026
70083d6
docs: update labels
StephenHulme Feb 6, 2026
21d346e
Merge branch 'develop' into y25-709-remove-obsolete-accessioning-code
StephenHulme Feb 6, 2026
08022ee
style: update rubocop todo
StephenHulme Feb 6, 2026
5c2d721
docs: clarify links
StephenHulme Feb 6, 2026
aca7e1e
docs: reorder arrows
StephenHulme Feb 6, 2026
033ea57
docs: add accessioning_enabled? flag
StephenHulme Feb 6, 2026
e05a749
docs: remove references to Limber charge and pass
StephenHulme Feb 6, 2026
c714d01
docs: rename nodes to not include SS prefix
StephenHulme Feb 6, 2026
a4e63ae
docs: cleanup
StephenHulme Feb 6, 2026
dee805b
docs: add more colour
StephenHulme Feb 6, 2026
295d924
Merge branch 'develop' into y25-697-send-all-library-labware
dasunpubudumal Feb 9, 2026
1f57afc
Merge pull request #5511 from sanger/y25-697-send-all-library-labware
dasunpubudumal Feb 9, 2026
1ac271c
fix: add missing accessioning-enabled guard clauses
StephenHulme Feb 9, 2026
597434b
refactor: improve reability of if statement
StephenHulme Feb 9, 2026
641aeea
style: add reminder that some checks don't belong in a model
StephenHulme Feb 9, 2026
71757ff
fix: add more missing accessioning-enabled guard clauses
StephenHulme Feb 9, 2026
55b09b9
refactor: move accession_all_samples out of study model
StephenHulme Feb 9, 2026
80eed30
docs: fix minor logical errors
StephenHulme Feb 9, 2026
5d77642
fix: repair missing model reference
StephenHulme Feb 9, 2026
546042e
test: update tests to match code changes
StephenHulme Feb 9, 2026
243c5ff
docs: move links to inside models
StephenHulme Feb 9, 2026
e0d10f2
docs: update legend
StephenHulme Feb 9, 2026
7b1deaf
docs: refactor diagram into 8 different processes
StephenHulme Feb 9, 2026
32fb219
docs: remove users
StephenHulme Feb 9, 2026
b9dab24
Update faraday to version 2.14.1
depfu[bot] Feb 9, 2026
69961ba
docs: straighten lines
StephenHulme Feb 10, 2026
df2a07c
Merge pull request #5535 from sanger/depfu/update/faraday-2.14.1
StephenHulme Feb 10, 2026
445d5b5
docs: remove old diagrams
StephenHulme Feb 10, 2026
9fe5331
tests: add additional helper specs
StephenHulme Feb 10, 2026
3fa9e63
tests: add additional controller specs
StephenHulme Feb 10, 2026
03e9f4f
test: remove extraneous lets
StephenHulme Feb 10, 2026
0464d6f
build: more gitignore to root directory
StephenHulme Feb 10, 2026
90e32fc
docs: increase fontsize
StephenHulme Feb 10, 2026
2f9b4d6
Merge pull request #5531 from sanger/y25-286-add-missing-accessioning…
StephenHulme Feb 11, 2026
6c0ad46
fix: add missing safe navigation operators to fix humanize on nil error
StephenHulme Feb 11, 2026
8fc8826
Merge pull request #5539 from sanger/y25-286-fix-humanize-bug
StephenHulme Feb 11, 2026
777f7ce
docs: highlight functions that call validations
StephenHulme Feb 11, 2026
74fc35b
Update bootsnap to version 1.22.0
depfu[bot] Feb 11, 2026
b0ef8bb
Use Ultima tag groups and tags from database for Barcode_Plate_Num an…
yoldas Feb 11, 2026
9511631
Fix typo in comment
yoldas Feb 11, 2026
dba36c2
Set the order of Ultima tag groups explicitly
yoldas Feb 12, 2026
750e732
refactor: remove unused InvalidData
StephenHulme Feb 12, 2026
64a2ded
Add test for matching z-index, oligo, and plate number in files
yoldas Feb 12, 2026
dc93d51
Merge branch 'develop' into y25-709-remove-obsolete-accessioning-code
StephenHulme Feb 12, 2026
168af98
Update knapsack_pro to version 9.2.2
depfu[bot] Feb 12, 2026
b88bcc3
Sort iteration of aliquots to avoid row shuffling
yoldas Feb 12, 2026
1f352d5
Merge pull request #5484 from sanger/y25-709-remove-obsolete-accessio…
StephenHulme Feb 13, 2026
6a3ed59
docs: more accession diagram up a level
StephenHulme Feb 13, 2026
7d09d50
Merge pull request #5504 from sanger/y25-708-update-accessioning-diagram
StephenHulme Feb 13, 2026
9ca01ca
Merge pull request #5543 from sanger/depfu/update/knapsack_pro-9.2.2
StephenHulme Feb 13, 2026
d978512
Merge pull request #5540 from sanger/depfu/update/bootsnap-1.22.0
StephenHulme Feb 13, 2026
f535a92
fix: encapsulate samples not accessioned text
StephenHulme Feb 13, 2026
cb0c98f
fix: handle singular case and no samples
StephenHulme Feb 13, 2026
075f034
Merge pull request #5544 from sanger/y25-286-samples-not-accessioned-…
StephenHulme Feb 16, 2026
77a8683
Merge branch 'develop' into ultima-sample-sheet-index-barcode-num
yoldas Feb 16, 2026
d0d998c
Merge pull request #5541 from sanger/ultima-sample-sheet-index-barcod…
yoldas Feb 16, 2026
f097500
Update .release-version to 14.87.0
yoldas Feb 16, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ doc/*
.yardoc/*
app/sample_manifest_excel/doc/

# Ignore generated diagrams from Mermaid
docs/accessioning/**/*.png
docs/accessioning/**/*.svg

# Test files
capybara*.html
spec/examples.txt
Expand Down
2 changes: 1 addition & 1 deletion .release-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
14.86.0
14.87.0
40 changes: 15 additions & 25 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config --no-exclude-limit`
# on 2026-02-06 11:06:52 UTC using RuboCop version 1.84.1.
# on 2026-02-06 14:12:50 UTC using RuboCop version 1.84.1.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
Expand Down Expand Up @@ -126,7 +126,7 @@ Lint/DuplicateMethods:
- 'app/models/stock_stamper.rb'
- 'lib/accession/tag.rb'

# Offense count: 63
# Offense count: 62
# Configuration parameters: AllowComments, AllowEmptyLambdas.
Lint/EmptyBlock:
Exclude:
Expand Down Expand Up @@ -164,7 +164,6 @@ Lint/EmptyBlock:
- 'app/api/endpoints/users.rb'
- 'app/api/endpoints/uuids.rb'
- 'app/api/endpoints/wells.rb'
- 'app/models/accessionable/sample.rb'
- 'app/models/plate.rb'
- 'app/models/request/library_creation.rb'
- 'app/sequencescape_excel/sequencescape_excel/list.rb'
Expand Down Expand Up @@ -194,12 +193,11 @@ Lint/IneffectiveAccessModifier:
- 'app/helpers/plates_helper.rb'
- 'lib/authenticated_system.rb'

# Offense count: 14
# Offense count: 13
# Configuration parameters: AllowedParentClasses.
Lint/MissingSuper:
Exclude:
- 'app/models/accession_service/no_service.rb'
- 'app/models/accession_service/unsuitable_service.rb'
- 'app/models/delegate_validation.rb'
- 'app/models/request/change_decision.rb'
- 'app/models/sample_manifest/library_tube_behaviour.rb'
Expand Down Expand Up @@ -240,7 +238,7 @@ Lint/StructNewOverride:
Exclude:
- 'app/models/product_criteria/basic.rb'

# Offense count: 61
# Offense count: 57
# This cop supports safe autocorrection (--autocorrect).
Lint/UselessAssignment:
Exclude:
Expand Down Expand Up @@ -580,18 +578,16 @@ Performance/MethodObjectAsBlock:
- 'features/support/step_definitions/transfer_steps.rb'
- 'lib/tasks/report.rake'

# Offense count: 3
# Offense count: 2
RSpec/AnyInstance:
Exclude:
- 'spec/controllers/samples_controller_spec.rb'
- 'spec/controllers/studies_controller_spec.rb'
- 'spec/models/lane_spec.rb'

# Offense count: 24
# Offense count: 22
RSpec/BeforeAfterAll:
Exclude:
- 'spec/features/sample_manifests/uploader_for_manifests_with_tag_sequences_spec.rb'
- 'spec/lib/accession/contact_spec.rb'
- 'spec/models/sample_manifest/generator_spec.rb'
- 'spec/models/sample_manifest/uploader_spec.rb'
- 'spec/sample_manifest_excel/download_spec.rb'
Expand All @@ -603,7 +599,7 @@ RSpec/BeforeAfterAll:
- 'spec/sample_manifest_excel/worksheet_spec.rb'
- 'spec/sequencescape_excel/worksheet_spec.rb'

# Offense count: 341
# Offense count: 342
# Configuration parameters: Prefixes, AllowedPatterns.
# Prefixes: when, with, without
RSpec/ContextWording:
Expand Down Expand Up @@ -684,7 +680,7 @@ RSpec/EmptyExampleGroup:
- 'spec/models/pulldown/requests_spec.rb'
- 'spec/models/tag_substitutions_spec.rb'

# Offense count: 376
# Offense count: 377
# Configuration parameters: Max, CountAsOne.
RSpec/ExampleLength:
Exclude:
Expand Down Expand Up @@ -828,14 +824,13 @@ RSpec/ExampleWording:
- 'spec/sequencescape_excel/validation_spec.rb'
- 'spec/sequencescape_excel/worksheet_spec.rb'

# Offense count: 258
# Offense count: 257
# Configuration parameters: AssignmentOnly.
RSpec/InstanceVariable:
Exclude:
- 'spec/api/extraction_attributes_spec.rb'
- 'spec/controllers/studies_controller_spec.rb'
- 'spec/controllers/submissions_controller_spec.rb'
- 'spec/lib/accession/contact_spec.rb'
- 'spec/models/orders/order_spec.rb'
- 'spec/models/pulldown/requests_spec.rb'
- 'spec/models/qc_report_spec.rb'
Expand Down Expand Up @@ -877,7 +872,7 @@ RSpec/LeakyLocalVariable:
- 'spec/models/well_spec.rb'
- 'spec/shared_contexts/it_requires_login.rb'

# Offense count: 38
# Offense count: 39
RSpec/LetSetup:
Exclude:
- 'spec/controllers/searches_controller_spec.rb'
Expand Down Expand Up @@ -938,7 +933,7 @@ RSpec/MultipleDescribes:
- 'spec/lib/label_printer/asset_labels_spec.rb'
- 'spec/models/qc_result/qc_result_spec.rb'

# Offense count: 926
# Offense count: 925
# Configuration parameters: Max.
RSpec/MultipleExpectations:
Exclude:
Expand Down Expand Up @@ -980,7 +975,6 @@ RSpec/MultipleExpectations:
- 'spec/jobs/export_pool_xp_to_traction_job_spec.rb'
- 'spec/lib/accession/accessionable_spec.rb'
- 'spec/lib/accession/configuration_spec.rb'
- 'spec/lib/accession/contact_spec.rb'
- 'spec/lib/accession/sample_spec.rb'
- 'spec/lib/accession/service_spec.rb'
- 'spec/lib/accession/submission_spec.rb'
Expand Down Expand Up @@ -1168,7 +1162,7 @@ RSpec/MultipleExpectations:
- 'spec/views/labware/show_chromium_chip_spec.rb'
- 'spec/views/samples/index_html_erb_spec.rb'

# Offense count: 248
# Offense count: 246
# Configuration parameters: EnforcedStyle, IgnoreSharedExamples.
# SupportedStyles: always, named_only
RSpec/NamedSubject:
Expand All @@ -1186,7 +1180,6 @@ RSpec/NamedSubject:
- 'spec/api/work_completion_spec.rb'
- 'spec/controllers/studies/information_controller_spec.rb'
- 'spec/controllers/studies_controller_spec.rb'
- 'spec/lib/accession/contact_spec.rb'
- 'spec/lib/label_printer/sample_manifest_plate_double_spec.rb'
- 'spec/models/aliquot_spec.rb'
- 'spec/models/api/library_tube_io_spec.rb'
Expand Down Expand Up @@ -1899,7 +1892,7 @@ Style/Not:
- 'app/views/batches/show.xml.builder'
- 'features/support/step_definitions/api_steps.rb'

# Offense count: 32
# Offense count: 30
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: EnforcedStyle, AllowedMethods, AllowedPatterns.
# SupportedStyles: predicate, comparison
Expand All @@ -1917,7 +1910,6 @@ Style/NumericPredicate:
- 'app/models/study.rb'
- 'app/models/tag_layout/walk_wells_by_pools.rb'
- 'app/models/well_attribute.rb'
- 'features/support/step_definitions/samples_steps.rb'
- 'lib/deployed.rb'
- 'lib/submission_serializer.rb'

Expand Down Expand Up @@ -2035,14 +2027,13 @@ Style/Proc:
- 'app/models/lib_pool_norm_tube_generator.rb'
- 'app/models/qcable/statemachine.rb'

# Offense count: 4
# Offense count: 3
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: Methods.
Style/RedundantArgument:
Exclude:
- 'app/models/plate/fluidigm_behaviour.rb'
- 'app/models/study_report/study_details.rb'
- 'features/support/step_definitions/samples_steps.rb'
- 'spec/features/shared_examples/cherrypicking.rb'

# Offense count: 7
Expand Down Expand Up @@ -2138,10 +2129,9 @@ Style/SymbolProc:
- 'app/models/tasks/plate_transfer_handler.rb'
- 'db/seeds/0001_workflows.rb'

# Offense count: 8
# Offense count: 6
# This cop supports unsafe autocorrection (--autocorrect-all).
Style/ZeroLengthPredicate:
Exclude:
- 'app/models/bulk_submission.rb'
- 'app/models/sequencing_pipeline.rb'
- 'features/support/step_definitions/samples_steps.rb'
10 changes: 5 additions & 5 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ GEM
base64 (0.3.0)
benchmark (0.5.0)
bigdecimal (3.3.1)
bootsnap (1.21.1)
bootsnap (1.22.0)
msgpack (~> 1.2)
builder (3.3.0)
bullet (8.1.0)
Expand Down Expand Up @@ -236,7 +236,7 @@ GEM
factory_bot_rails (6.5.1)
factory_bot (~> 6.5)
railties (>= 6.1.0)
faraday (2.14.0)
faraday (2.14.1)
faraday-net_http (>= 2.0, < 3.5)
json
logger
Expand Down Expand Up @@ -289,7 +289,7 @@ GEM
railties (>= 4.1)
jsonapi-resources-matchers (1.0.0)
jsonapi-resources (>= 0.9.0)
knapsack_pro (9.2.1)
knapsack_pro (9.2.2)
rake
language_server-protocol (3.17.0.5)
launchy (3.1.1)
Expand Down Expand Up @@ -338,8 +338,8 @@ GEM
mutex_m (0.3.0)
mysql2 (0.5.7)
bigdecimal
net-http (0.7.0)
uri
net-http (0.9.1)
uri (>= 0.11.1)
net-imap (0.5.9)
date
net-protocol
Expand Down
28 changes: 8 additions & 20 deletions app/controllers/samples_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def show_accession
end
end

def accession # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
def accession # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
# @sample needs to be set before initially for use in the ensure block
@sample = Sample.find(params[:id])

Expand All @@ -165,18 +165,11 @@ def accession # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Met
# return
# end

# Must check if an accession number is assigned _before_ performing the accession
accession_action = @sample.accession_number? ? :update : :create

if Flipper.enabled?(:y25_286_accession_individual_samples_with_sample_accessioning_job)
# Synchronously perform accessioning job
Accession.accession_sample(@sample, current_user, perform_now: true)
else
# TODO: when removing the y25_286_accession_individual_samples_with_sample_accessioning_job feature flag
# and this accessioning path also remove the AccessionService and ActiveRecord errors below
@sample.validate_sample_for_accessioning!
accession_service = AccessionService.select_for_sample(@sample)
accession_service.submit_sample_for_user(@sample, current_user)
end
# Synchronously perform accessioning job
Accession.accession_sample(@sample, current_user, perform_now: true)

if accession_action == :create
flash[:notice] = "Accession number generated: #{@sample.sample_metadata.sample_ebi_accession_number}"
Expand All @@ -185,23 +178,18 @@ def accession # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Met
end

# Handle errors for both synchronous and asynchronous accessioning
# When the feature flag above (y25_286_accession_individual_samples_with_sample_accessioning_job) is removed,
# the AccessionService and ActiveRecord errors should also be removed. These errors are only raised in the old
# synchronous accessioning code path and are not required for the updated SampleAccessioningJob path.
rescue ActiveRecord::RecordInvalid, Accession::InternalValidationError
rescue Accession::InternalValidationError
flash[:error] = "Please fill in the required fields: #{@sample.errors.full_messages.join(', ')}"
redirect_to(edit_sample_path(@sample)) # send the user to edit the sample
rescue AccessionService::NumberNotRequired => e
flash[:warning] = e.message || 'An accession number is not required for this study'
rescue AccessionService::NumberNotGenerated, Accession::ExternalValidationError => e
rescue Accession::ExternalValidationError => e
flash[:warning] = "No accession number was generated: #{e.message}"
rescue AccessionService::AccessionServiceError, Accession::Error => e
rescue Accession::Error => e
flash[:error] = "Accessioning Service Failed: #{e.message}"
rescue Faraday::Error => e
flash[:error] = "Accessioning failed with a network error: #{e.message}"
ensure
# Redirect back to where we came from if not already redirected
redirect_back_with_anchor_or_to(sample_path(@sample), anchor: 'accession-statuses') unless performed?
redirect_back_with_anchor_or_to(sample_path(@sample)) unless performed?
end

private
Expand Down
34 changes: 30 additions & 4 deletions app/controllers/studies_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -253,23 +253,49 @@ def accession
end
end

# Accession all samples in the study.
#
# If the study does not have an accession number, adds an error to the study and returns.
# Otherwise, iterates through each sample in the study and attempts to accession it,
# unless the sample already has an accession number.
# If an Accession::Error occurs for a sample, adds the error message to the study's errors.
#
# NOTE: this does not check if the current user has permission to accession samples in this study
#
# @return [void]
def accession_all_samples # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
@study = Study.find(params[:id])
return accessioning_not_enabled_redirect unless accessioning_enabled?

# TODO: Y26-026 - Enforce accessioning permissions
# return accession_permission_denied_redirect unless permitted_to_accession?(@study)

@study.accession_all_samples(current_user)
unless @study.accession_number?
flash[:error] = 'Please accession the study before accessioning samples'
return redirect_to(study_path(@study))
end
unless @study.samples_accessionable?
flash[:error] = 'Study cannot accession samples, see Study Accessioning tab for details'
return redirect_to(study_path(@study))
end

@study.samples.find_each do |sample|
next if sample.accession_number?

begin
Accession.accession_sample(sample, current_user)
rescue Accession::Error => e
@study.errors.add(:base, e.message)
end
end

if @study.errors.any?
error_messages = compile_accession_errors(@study.errors)
flash[:error] = error_messages
flash[:error] = compile_accession_errors(@study.errors)
else
flash[:notice] = 'All of the samples in this study have been sent for accessioning. ' \
'Please check back in 5 minutes to confirm that accessioning was successful.'
end
redirect_to(study_path(@study, anchor: 'accession-statuses'))
redirect_to(study_path(@study))
end

def dac_accession
Expand Down
Loading
Loading