Module: StudyReport::StudyDetails

Included in:
Study
Defined in:
app/models/study_report/study_details.rb

Overview

rubocop:todo Metrics/ModuleLength

Constant Summary collapse

BATCH_SIZE =

rubocop:todo Style/Documentation

1000

Instance Method Summary collapse

Instance Method Details

#each_stock_well_id_in_study_in_batches(&block) ⇒ Object

This will pull out all well ids from stock plates in the study


7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/models/study_report/study_details.rb', line 7

def each_stock_well_id_in_study_in_batches(&block)
  # Stock wells are determined by the requests leading from the stock plate
  handle_wells(
    :requests,
    { requests: { initial_study_id: id } },
    PlatePurpose.where(name: Study::STOCK_PLATE_PURPOSES).pluck(:id),
    &block
  )

  # Aliquot 1,2,3,4 & 5 plates are determined by the aliquots in their wells
  handle_wells(
    :aliquots,
    { aliquots: { study_id: id } },
    PlatePurpose
      .where(name: ['Aliquot 1', 'Aliquot 2', 'Aliquot 3', 'Aliquot 4', 'Aliquot 1', 'Pre-Extracted Plate'])
      .pluck(:id),
    &block
  )
end

#progress_report_headerObject


40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'app/models/study_report/study_details.rb', line 40

def progress_report_header
  [
    'Status',
    'Study',
    'Supplier',
    'Sanger Sample Name',
    'Supplier Sample Name',
    'Plate',
    'Well',
    'Supplier Volume',
    'Supplier Gender',
    'Concentration',
    'Initial Volume',
    'Current Volume',
    'Total Micrograms',
    'Sequenome Count',
    'Sequenome Gender',
    'Pico',
    'Gel',
    'Qc Status',
    'QC started date',
    'Pico date',
    'Gel QC date',
    'Seq stamp date',
    'Cohort',
    'Country of Origin',
    'Geographical Region',
    'Ethnicity',
    'DNA Source',
    'Is Resubmitted',
    'Control',
    'Is in Fluidigm'
  ]
end

#progress_report_on_all_assets {|progress_report_header| ... } ⇒ Object

rubocop:todo Metrics/MethodLength


76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'app/models/study_report/study_details.rb', line 76

def progress_report_on_all_assets # rubocop:todo Metrics/AbcSize
  yield(progress_report_header)

  each_stock_well_id_in_study_in_batches do |asset_ids|
    # eager loading of well_attribute , can only be done on  wells ...
    # We've already split into batches, so find_each here only slows things down.
    Well
      .for_study_report
      .where(id: asset_ids)
      .each do |asset|
        asset_progress_data = asset.qc_report
        next if asset_progress_data.nil?

        yield(
          [
            asset_progress_data[:status],
            name,
            asset_progress_data[:supplier],
            asset_progress_data[:sanger_sample_id],
            asset_progress_data[:sample_name],
            asset_progress_data[:plate_barcode],
            asset_progress_data[:well],
            asset_progress_data[:supplier_volume],
            asset_progress_data[:supplier_gender],
            asset_progress_data[:concentration],
            asset_progress_data[:initial_volume],
            asset_progress_data[:current_volume],
            asset_progress_data[:quantity],
            asset_progress_data[:sequenom_count],
            [(asset_progress_data[:sequenom_gender])].flatten.compact.join(''),
            asset_progress_data[:pico],
            asset_progress_data[:gel],
            asset_progress_data[:qc_status],
            asset_progress_data[:qc_started_date],
            asset_progress_data[:pico_date],
            asset_progress_data[:gel_qc_date],
            asset_progress_data[:sequenom_stamp_date],
            asset_progress_data[:cohort],
            asset_progress_data[:country_of_origin],
            asset_progress_data[:geographical_region],
            asset_progress_data[:ethnicity],
            asset_progress_data[:dna_source],
            asset_progress_data[:is_resubmitted],
            asset_progress_data[:control],
            asset_progress_data[:is_in_fluidigm]
          ]
        )
      end
  end
end