From ce7ab899344dda50dc9dd99e4698b0a0629607e1 Mon Sep 17 00:00:00 2001 From: simon lehericey Date: Wed, 27 Nov 2019 14:56:08 +0100 Subject: [PATCH] Add purge stale export job --- README.md | 1 + app/jobs/purge_stale_export_jobs.rb | 7 +++++++ .../deployment/20191127135401_enable_export_purge.rake | 8 ++++++++ 3 files changed, 16 insertions(+) create mode 100644 app/jobs/purge_stale_export_jobs.rb create mode 100644 lib/tasks/deployment/20191127135401_enable_export_purge.rake diff --git a/README.md b/README.md index d64b44dbd..abd5ae103 100644 --- a/README.md +++ b/README.md @@ -78,6 +78,7 @@ En local, un utilisateur de test est créé automatiquement, avec les identifian PurgeUnattachedBlobsJob.set(cron: "0 0 * * *").perform_later OperationsSignatureJob.set(cron: "0 6 * * *").perform_later SeekAndDestroyExpiredDossiersJob.set(cron: "0 7 * * *").perform_later + PurgeStaleExportsJob.set(cron: "*/5 * * * *").perform_later ### Voir les emails envoyés en local diff --git a/app/jobs/purge_stale_export_jobs.rb b/app/jobs/purge_stale_export_jobs.rb new file mode 100644 index 000000000..6a40feec6 --- /dev/null +++ b/app/jobs/purge_stale_export_jobs.rb @@ -0,0 +1,7 @@ +class PurgeStaleExportsJob < ApplicationJob + queue_as :cron + + def perform + Export.stale.destroy_all + end +end diff --git a/lib/tasks/deployment/20191127135401_enable_export_purge.rake b/lib/tasks/deployment/20191127135401_enable_export_purge.rake new file mode 100644 index 000000000..50c297cdc --- /dev/null +++ b/lib/tasks/deployment/20191127135401_enable_export_purge.rake @@ -0,0 +1,8 @@ +namespace :after_party do + desc 'Deployment task: enable_export_purge' + task enable_export_purge: :environment do + PurgeStaleExportsJob.set(cron: "*/5 * * * *").perform_later + + AfterParty::TaskRecord.create version: '20191127135401' + end +end