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.
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'app/models/lab_tech/experiment.rb', line 100 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_attributes( equivalent_count: 0, timed_out_count: 0, other_error_count: 0, ) puts "Deleted #{m} result(s) and #{n} observations" end |