From 4442338a68a2f130f104b5b5fffdb8d54639440e Mon Sep 17 00:00:00 2001 From: f Date: Wed, 29 Mar 2023 14:57:30 -0300 Subject: [PATCH] feat: realizar la limpieza en segundo plano --- app/jobs/cleanup_job.rb | 8 ++++++++ lib/tasks/cleanup.rake | 4 +--- 2 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 app/jobs/cleanup_job.rb diff --git a/app/jobs/cleanup_job.rb b/app/jobs/cleanup_job.rb new file mode 100644 index 00000000..13053cb0 --- /dev/null +++ b/app/jobs/cleanup_job.rb @@ -0,0 +1,8 @@ +# frozen_string_literal: true + +# Realiza tareas de limpieza en segundo plano +class CleanupJob < ApplicationJob + def perform(before = nil) + CleanupService.new(before: before).cleanup_everything! + end +end diff --git a/lib/tasks/cleanup.rake b/lib/tasks/cleanup.rake index e14693bc..1c52abaf 100644 --- a/lib/tasks/cleanup.rake +++ b/lib/tasks/cleanup.rake @@ -4,8 +4,6 @@ namespace :cleanup do desc 'Cleanup sites' task everything: :environment do before = ENV.fetch('BEFORE', '30').to_i.days.ago - service = CleanupService.new(before: before) - - service.cleanup_everything! + CleanupJob.perform_later(before) end end