Class: SampleAccessioningJob

Inherits:
Struct
  • Object
show all
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

Instance Method Summary collapse

Instance Attribute Details

#accessionableObject

Returns the value of attribute accessionable

Returns:

  • (Object)

    the current value of accessionable



9
10
11
# File 'app/jobs/sample_accessioning_job.rb', line 9

def accessionable
  @accessionable
end

#event_userObject

Returns the value of attribute event_user

Returns:

  • (Object)

    the current value of event_user



9
10
11
# File 'app/jobs/sample_accessioning_job.rb', line 9

def event_user
  @event_user
end

Instance Method Details

#before(_job) ⇒ Object

Called before the job is run



58
59
60
# File 'app/jobs/sample_accessioning_job.rb', line 58

def before(_job)
  progress_accession_status
end

#enqueue(_job) ⇒ Object

Called when the job is initially enqueued



53
54
55
# File 'app/jobs/sample_accessioning_job.rb', line 53

def enqueue(_job)
  create_queued_accession_status
end

#failure(_job) ⇒ Object

Called after the job has failed max_attempts times



68
69
70
# File 'app/jobs/sample_accessioning_job.rb', line 68

def failure(_job)
  abort_accession_status
end

#max_attemptsObject



27
28
29
30
# File 'app/jobs/sample_accessioning_job.rb', line 27

def max_attempts
  # When changing, also update attempt description text in app/views/samples/_accession_statuses.html.erb
  3
end

#performObject



11
12
13
14
15
16
17
18
19
20
# File 'app/jobs/sample_accessioning_job.rb', line 11

def perform
  submission = Accession::Submission.new(accessionable)
  accessionable.validate! # See Accession::Sample.validate! in lib/accession/sample.rb
  submission.submit_accession(event_user)
  Rails.logger.info("Accessioning succeeded for sample '#{accessionable.sample.name}'")
rescue StandardError => e
  handle_job_error(e, submission)

  raise # Raising an error signals that the job should be retried at a later time
end

#queue_nameObject



32
33
34
# File 'app/jobs/sample_accessioning_job.rb', line 32

def queue_name
  'sample_accessioning'
end

#reschedule_at(current_time, _attempts) ⇒ Object



22
23
24
25
# File 'app/jobs/sample_accessioning_job.rb', line 22

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



63
64
65
# File 'app/jobs/sample_accessioning_job.rb', line 63

def success(_job)
  succeed_accession_status
end