Class: ChecksumAuditLog

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

Overview

Copyright © 2012 The Pennsylvania State University

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Class Method Summary collapse

Class Method Details

.get_audit_log(version) ⇒ Object



18
19
20
21
22
23
# File 'app/models/checksum_audit_log.rb', line 18

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

.prune_history(version) ⇒ Object



25
26
27
28
29
30
31
32
33
34
# File 'app/models/checksum_audit_log.rb', line 25

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.find(version.pid).logs(version.dsid)
  list = logs.limit(2)
  if list.size > 1 && (list[0].pass == 1) && (list[1].pass == 1)
    list[0].delete 
  end
end