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

Constant Summary collapse

JobFailed =
Class.new(StandardError)

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


5
6
7
# File 'app/jobs/sample_accessioning_job.rb', line 5

def accessionable
  @accessionable
end

Instance Method Details

#max_attemptsObject


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

def max_attempts
  3
end

#performObject


9
10
11
12
13
14
15
16
# File 'app/jobs/sample_accessioning_job.rb', line 9

def perform
  submission = Accession::Submission.new(User.find_by(api_key: configatron.accession_local_key), accessionable)
  submission.post

  # update_accession_number returns true if an accession has been supplied, and the sample has been saved.
  # If this returns false, then we fail the job. This should catch any failure situations
  submission.update_accession_number || raise(JobFailed)
end

#queue_nameObject


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

def queue_name
  'sample_accessioning'
end

#reschedule_at(current_time, _attempts) ⇒ Object


18
19
20
# File 'app/jobs/sample_accessioning_job.rb', line 18

def reschedule_at(current_time, _attempts)
  current_time + 1.day
end