Class: StudyReport

Inherits:
ApplicationRecord show all
Extended by:
DbFile::Uploader
Defined in:
app/models/study_report.rb

Defined Under Namespace

Modules: AssetDetails, StudyDetails, WellDetails Classes: ProcessingError

Instance Method Summary collapse

Methods included from DbFile::Uploader

extended, has_uploaded

Methods inherited from ApplicationRecord

convert_labware_to_receptacle_for, find_by_id_or_name, find_by_id_or_name!

Methods included from Warren::BroadcastMessages

#broadcast, included, #queue_associated_for_broadcast, #queue_for_broadcast, #warren

Instance Method Details

#headersObject


19
20
21
22
23
24
25
26
# File 'app/models/study_report.rb', line 19

def headers
  [
    'Study', 'Sample Name', 'Plate', 'Supplier Volume', 'Supplier Concentration',
    'Supplier Sample Name', 'Supplier Gender', 'Concentration',
    'Sequenome Count', 'Sequenome Gender', 'Pico', 'Gel', 'Qc Status',
    'Genotyping Status', 'Genotyping Chip', 'Is in Fluidigm'
  ]
end

#performObject


28
29
30
31
32
33
34
35
36
37
38
39
# File 'app/models/study_report.rb', line 28

def perform
  ActiveRecord::Base.transaction do
    csv_options = { row_sep: "\r\n", force_quotes: true }
    Tempfile.open("#{study.dehumanise_abbreviated_name}_progress_report.csv") do |tempfile|
      Study.find(study_id).progress_report_on_all_assets do |fields|
        tempfile.puts(CSV.generate_line(fields, csv_options))
      end
      tempfile.open # Reopen the temporary file
      update!(report: tempfile)
    end
  end
end

#priorityObject


45
46
47
# File 'app/models/study_report.rb', line 45

def priority
  configatron.delayed_job.fetch(:study_report_priority, 100)
end

#schedule_reportObject


41
42
43
# File 'app/models/study_report.rb', line 41

def schedule_report
  Delayed::Job.enqueue StudyReportJob.new(id), priority: priority
end