Class: ChecksumAuditLog
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- ChecksumAuditLog
- Defined in:
- app/models/checksum_audit_log.rb
Class Method Summary collapse
- .get_audit_log(id, path, version_uri) ⇒ Object
- .logs_for(id, path) ⇒ Object
-
.prune_history(id, path) ⇒ Object
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.
Class Method Details
.get_audit_log(id, path, version_uri) ⇒ Object
2 3 4 |
# File 'app/models/checksum_audit_log.rb', line 2 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 |
.logs_for(id, path) ⇒ Object
17 18 19 |
# File 'app/models/checksum_audit_log.rb', line 17 def self.logs_for(id, path) ChecksumAuditLog.where(file_set_id: id, file_id: path).order('created_at desc, id desc') end |
.prune_history(id, path) ⇒ Object
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
10 11 12 13 14 15 |
# File 'app/models/checksum_audit_log.rb', line 10 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 |