Sha256: 01db1ebbdb4b32e9e8b4b1f6eaa529ff112aa3d542e4739c5ad81c799385dba3

Contents?: true

Size: 816 Bytes

Versions: 4

Compression:

Stored size: 816 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

4 entries across 4 versions & 2 rubygems

Version Path
sufia-models-6.2.0 app/models/checksum_audit_log.rb
sufia-models-6.1.0 app/models/checksum_audit_log.rb
sufia-models-6.0.0 app/models/checksum_audit_log.rb
sufia-6.0.0 sufia-models/app/models/checksum_audit_log.rb