Class: StudyReport

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

Overview

A spreadsheet summarising the QC information about a study. Generally replaced by QcReport which adds support for pass/fail criteria, automatic decisions and customer decisions.

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 Squishify

extended

Instance Method Details

#headersObject


22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'app/models/study_report.rb', line 22

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


43
44
45
46
47
48
49
50
51
52
53
54
# File 'app/models/study_report.rb', line 43

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 { |fields| tempfile.puts(CSV.generate_line(fields, csv_options)) }
      tempfile.open # Reopen the temporary file
      update!(report: tempfile)
    end
  end
end

#priorityObject


60
61
62
# File 'app/models/study_report.rb', line 60

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

#schedule_reportObject


56
57
58
# File 'app/models/study_report.rb', line 56

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