Sha256: 6c3736360ad5a514cb1f989634d8614c8cda650695d7cfcd8fc6c0658f103735

Contents?: true

Size: 815 Bytes

Versions: 6

Compression:

Stored size: 815 Bytes

Contents

class ChecksumAuditLog < ActiveRecord::Base
  def self.get_audit_log(id, path, version_uri)
    ChecksumAuditLog.find_or_create_by(generic_file_id: id, dsid: path, version: version_uri)
  end

  # Check to see if there are previous passing logs that we can delete
  # we want to keep the first passing event after a failure, the most current passing event,
  # and all failures so that this table doesn't grow too large
  # Simple way (a little naieve): if the last 2 were passing, delete the first one
  def self.prune_history(id, path)
    list = logs_for(id, path).limit(2)
    if list.size > 1 && (list[0].pass == 1) && (list[1].pass == 1)
      list[0].destroy
    end
  end

  def self.logs_for(id, path)
    ChecksumAuditLog.where(generic_file_id: id, dsid: path).order('created_at desc, id desc')
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
sufia-models-6.7.0 app/models/checksum_audit_log.rb
sufia-models-6.6.1 app/models/checksum_audit_log.rb
sufia-models-6.6.0 app/models/checksum_audit_log.rb
sufia-models-6.5.0 app/models/checksum_audit_log.rb
sufia-models-6.4.0 app/models/checksum_audit_log.rb
sufia-models-6.3.0 app/models/checksum_audit_log.rb