From 02671f1872d09a8b411abe6bd535b3fccbc9dae2 Mon Sep 17 00:00:00 2001 From: Oleg Hasjanov Date: Wed, 12 Jul 2023 15:06:19 +0300 Subject: [PATCH] added task for run job --- lib/tasks/check_for_company_status.rake | 35 +++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 lib/tasks/check_for_company_status.rake diff --git a/lib/tasks/check_for_company_status.rake b/lib/tasks/check_for_company_status.rake new file mode 100644 index 0000000000..7c2418f133 --- /dev/null +++ b/lib/tasks/check_for_company_status.rake @@ -0,0 +1,35 @@ +require 'optparse' +require 'rake_option_parser_boilerplate' +require 'syslog/logger' +require 'active_record' + +DAYS_INTERVAL = 365 +SPAM_TIME_DELAY = 0.3 +BATCH_SIZE = 100 + +namespace :company_status do + # bundle exec rake company_status:check_all -- --days_interval=128 --spam_time_delay=0.3 --batch_size=100 + + desc 'Starts verifying registrant companies job with optional days interval, spam time delay and batch size' + task check_all: :environment do + options = { + days_interval: DAYS_INTERVAL, + spam_time_delay: SPAM_TIME_DELAY, + batch_size: BATCH_SIZE, + } + + opts_hash = { + days_interval: ["--days_interval=VALUE", Integer], + spam_time_delay: ["--spam_time_delay=VALUE", Float], + batch_size: ["--batch_size=VALUE", Integer] + } + + banner = 'Usage: rake company_status:check_all -- [options]' + options = RakeOptionParserBoilerplate.process_args(options: options, + banner: banner, + hash: opts_hash) + + + CompanyRegisterStatusJob.perform_later(options[:days_interval], options[:spam_time_delay], options[:batch_size]) + end +end