Class: ForemanCveScanner::ScanCleanup
- Inherits:
-
Object
- Object
- ForemanCveScanner::ScanCleanup
- Defined in:
- app/services/foreman_cve_scanner/scan_cleanup.rb
Constant Summary collapse
- SETTING_NAME =
:cve_scan_delete_after_days
Instance Method Summary collapse
- #cleanup! ⇒ Object
-
#initialize(scope: ::ForemanCveScanner::CveScan.all, days: nil) ⇒ ScanCleanup
constructor
A new instance of ScanCleanup.
Constructor Details
#initialize(scope: ::ForemanCveScanner::CveScan.all, days: nil) ⇒ ScanCleanup
Returns a new instance of ScanCleanup.
7 8 9 10 |
# File 'app/services/foreman_cve_scanner/scan_cleanup.rb', line 7 def initialize(scope: ::ForemanCveScanner::CveScan.all, days: nil) @scope = scope @days = days end |
Instance Method Details
#cleanup! ⇒ Object
12 13 14 15 16 17 18 |
# File 'app/services/foreman_cve_scanner/scan_cleanup.rb', line 12 def cleanup! return 0 unless retention_days.positive? deleted = @scope.where('scanned_at < ?', retention_cutoff).delete_all Rails.logger.info("Deleted #{deleted} CVE scans older than #{retention_days} days") if deleted.positive? deleted end |