Merge pull request #5808 from betagouv/fix_missing_antivirus_analysis

Add cron to complete missing analysis
This commit is contained in:
Paul Chavard 2020-12-17 11:21:09 +01:00 committed by GitHub
commit 515781b3ce
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -0,0 +1,12 @@
class Cron::FixMissingAntivirusAnalysis < Cron::CronJob
self.schedule_expression = "every day at 2 am"
def perform
ActiveStorage::Blob.where("metadata like '%\"virus_scan_result\":\"pending%'").each do |b|
begin
VirusScannerJob.perform_now(b)
rescue ActiveStorage::IntegrityError
end
end
end
end