Method: LabTech::Experiment#purge_data
- Defined in:
- app/models/lab_tech/experiment.rb
#purge_data ⇒ Object
I don’t encourage the willy-nilly destruction of experimental results… …but sometimes you just need to start over.
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'app/models/lab_tech/experiment.rb', line 112 def purge_data delete_and_count = ->(scope) { n0, n1 = 0, 0 transaction do n0 = scope.count scope.delete_all n1 = scope.count end n0 - n1 } n = delete_and_count.call( LabTech::Observation.where(result_id: self.result_ids) ) m = delete_and_count.call( self.results ) update( equivalent_count: 0, timed_out_count: 0, other_error_count: 0, ) puts "Deleted #{m} result(s) and #{n} observations" end |