app/models/lab_tech/experiment.rb
# I don't encourage the willy-nilly destruction of experimental results...
# ...but sometimes you just need to start over.
I don't encourage the willy-nilly destruction of experimental results
but sometimes you just need to start over.
I don ' t encourage the willy - nilly destruction of experimental results but sometimes you just need to start over .
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
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
I don't encourage the willy-nilly destruction of experimental results...
...but sometimes you just need to start over.
I don ' t encourage the willy - nilly destruction of experimental results ... ... but sometimes you just need to start over .