Sha256: 78128917c34a0dfbecec7a9e51cc20ae71a3810d029d26852a6b766e37fb8e17

Contents?: true

Size: 1.55 KB

Versions: 6

Compression:

Stored size: 1.55 KB

Contents

# 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
#
# http://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 ChecksumAuditLog < ActiveRecord::Base
  attr_accessible :pass, :pid, :dsid, :version, :created_at

  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

  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
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
sufia-2.0.1 sufia-models/app/models/checksum_audit_log.rb
sufia-models-2.0.1 app/models/checksum_audit_log.rb
sufia-2.0.0 sufia-models/app/models/checksum_audit_log.rb
sufia-models-2.0.0 app/models/checksum_audit_log.rb
sufia-models-0.1.2 app/models/checksum_audit_log.rb
sufia-models-0.1.1 app/models/checksum_audit_log.rb