Class: SampleAccessioningJob
- Inherits:
-
Struct
- Object
- Struct
- SampleAccessioningJob
- Defined in:
- app/jobs/sample_accessioning_job.rb
Overview
Sends sample data to the ENA or EGA in order to generate an accession number Records the generated accession number on the sample Records the statuses and response from the failed attempts in the accession statuses
Instance Attribute Summary collapse
-
#accessionable ⇒ Object
Returns the value of attribute accessionable.
-
#event_user ⇒ Object
Returns the value of attribute event_user.
Class Method Summary collapse
-
.contact_user ⇒ Object
Retrieve the contact user for accessioning submissions.
Instance Method Summary collapse
-
#before(_job) ⇒ Object
Called before the job is run.
-
#enqueue(_job) ⇒ Object
Called when the job is initially enqueued.
-
#failure(_job) ⇒ Object
Called after the job has failed max_attempts times.
- #max_attempts ⇒ Object
- #perform ⇒ Object
- #queue_name ⇒ Object
- #reschedule_at(current_time, _attempts) ⇒ Object
-
#success(_job) ⇒ Object
Called after the job has completed successfully.
Instance Attribute Details
#accessionable ⇒ Object
Returns the value of attribute accessionable
12 13 14 |
# File 'app/jobs/sample_accessioning_job.rb', line 12 def accessionable @accessionable end |
#event_user ⇒ Object
Returns the value of attribute event_user
12 13 14 |
# File 'app/jobs/sample_accessioning_job.rb', line 12 def event_user @event_user end |
Class Method Details
.contact_user ⇒ Object
Retrieve the contact user for accessioning submissions
15 16 17 |
# File 'app/jobs/sample_accessioning_job.rb', line 15 def self.contact_user User.find_by(api_key: configatron.accession_local_key) end |
Instance Method Details
#before(_job) ⇒ Object
Called before the job is run
67 68 69 |
# File 'app/jobs/sample_accessioning_job.rb', line 67 def before(_job) progress_accession_status end |
#enqueue(_job) ⇒ Object
Called when the job is initially enqueued
62 63 64 |
# File 'app/jobs/sample_accessioning_job.rb', line 62 def enqueue(_job) create_queued_accession_status end |
#failure(_job) ⇒ Object
Called after the job has failed max_attempts times
77 78 79 |
# File 'app/jobs/sample_accessioning_job.rb', line 77 def failure(_job) abort_accession_status end |
#max_attempts ⇒ Object
36 37 38 39 |
# File 'app/jobs/sample_accessioning_job.rb', line 36 def max_attempts # When changing, also update attempt description text in app/views/samples/_accession_statuses.html.erb 3 end |
#perform ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/jobs/sample_accessioning_job.rb', line 19 def perform contact_user = self.class.contact_user submission = Accession::Submission.new(contact_user, accessionable) submission.submit_and_update_accession_number(event_user) rescue StandardError => e handle_job_error(e, submission) # Raising an error to Delayed::Job will signal that the job should be retried at a later time = "#{e.class}: #{e.}" raise JobFailed, end |
#queue_name ⇒ Object
41 42 43 |
# File 'app/jobs/sample_accessioning_job.rb', line 41 def queue_name 'sample_accessioning' end |
#reschedule_at(current_time, _attempts) ⇒ Object
31 32 33 34 |
# File 'app/jobs/sample_accessioning_job.rb', line 31 def reschedule_at(current_time, _attempts) # When changing, also update attempt description text in app/views/samples/_accession_statuses.html.erb current_time + 1.day end |
#success(_job) ⇒ Object
Called after the job has completed successfully
72 73 74 |
# File 'app/jobs/sample_accessioning_job.rb', line 72 def success(_job) succeed_accession_status end |