From 9b2194ee950354573fdef604a49cdafb8141d0e7 Mon Sep 17 00:00:00 2001 From: f Date: Sat, 23 Apr 2022 15:24:06 -0300 Subject: [PATCH] detener la tarea --- app/jobs/periodic_job.rb | 8 ++++++++ app/jobs/uri_collection_job.rb | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/jobs/periodic_job.rb b/app/jobs/periodic_job.rb index 8d9453a3..2f60a2b3 100644 --- a/app/jobs/periodic_job.rb +++ b/app/jobs/periodic_job.rb @@ -52,4 +52,12 @@ class PeriodicJob < ApplicationJob def beginning_of_interval @beginning_of_interval ||= last_stat.created_at.try(:"beginning_of_#{starting_interval}") end + + def stop_file + @stop_file ||= Rails.root.join('tmp', self.class.to_s.tableize) + end + + def stop? + File.exist? stop_file + end end diff --git a/app/jobs/uri_collection_job.rb b/app/jobs/uri_collection_job.rb index 9ec333cd..b66a804d 100644 --- a/app/jobs/uri_collection_job.rb +++ b/app/jobs/uri_collection_job.rb @@ -21,7 +21,7 @@ class UriCollectionJob < PeriodicJob hostnames.each do |hostname| uris.each do |uri| - return if File.exist? Rails.root.join('tmp', 'uri_collection_job_stop') + return if stop? AccessLog.where(host: hostname, uri: uri) .where('created_at >= ?', beginning_of_interval)