Sha256: 6d7262871b4749c8e82ae7e9fac35e2881eb9b969e865dc182a8751360a08bbb

Contents?: true

Size: 806 Bytes

Versions: 10

Compression:

Stored size: 806 Bytes

Contents

class ChecksumAuditLog < ActiveRecord::Base
  def self.get_audit_log(id, path, version_uri)
    ChecksumAuditLog.find_or_create_by(file_set_id: id, file_id: 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 naive): if the last 2 were passing, delete the first one
  def self.prune_history(id, path)
    list = logs_for(id, path).limit(2)
    return if list.size <= 1 || list[0].pass != 1 || list[1].pass != 1
    list[0].destroy
  end

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

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
hyrax-1.1.1 app/models/checksum_audit_log.rb
hyrax-1.1.0 app/models/checksum_audit_log.rb
hyrax-1.0.5 app/models/checksum_audit_log.rb
hyrax-1.0.4 app/models/checksum_audit_log.rb
hyrax-1.0.3 app/models/checksum_audit_log.rb
hyrax-1.0.2 app/models/checksum_audit_log.rb
hyrax-1.0.1 app/models/checksum_audit_log.rb
hyrax-1.0.0.rc2 app/models/checksum_audit_log.rb
hyrax-1.0.0.rc1 app/models/checksum_audit_log.rb
test_hyrax-0.0.1.alpha app/models/checksum_audit_log.rb