Class: ChecksumAuditLog

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/checksum_audit_log.rb

Class Method Summary collapse

Class Method Details

.get_audit_log(version) ⇒ Object



3
4
5
6
7
# File 'app/models/checksum_audit_log.rb', line 3

def ChecksumAuditLog.get_audit_log(version)
  ChecksumAuditLog.find_or_create_by_pid_and_dsid_and_version(pid: version.pid,
                                                              dsid: version.dsid,
                                                              version: version.versionID)
end

.prune_history(version) ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'app/models/checksum_audit_log.rb', line 9

def ChecksumAuditLog.prune_history(version)
  ## 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
  logs = GenericFile.load_instance_from_solr(version.pid).logs(version.dsid)
  list = logs.limit(2)
  if list.size > 1 && (list[0].pass == 1) && (list[1].pass == 1)
    list[0].destroy
  end
end