Commit 6ab9a5d1 by Thanh Hung Pham

Config autoload file and schedule content update

parent 95480c2e
...@@ -24,4 +24,5 @@ set :output, { error: 'log/cron_error_log.log', standard: 'log/cron_log.log' } ...@@ -24,4 +24,5 @@ set :output, { error: 'log/cron_error_log.log', standard: 'log/cron_log.log' }
every 1.day, at: '12:00 pm' do every 1.day, at: '12:00 pm' do
rake 'crawler:load' rake 'crawler:load'
rake 'import:csv'
end end
...@@ -2,7 +2,7 @@ require 'thread' ...@@ -2,7 +2,7 @@ require 'thread'
require 'logger' require 'logger'
require 'csv' require 'csv'
class CSVReader class Import::CSVReader
attr_reader :thread_count, :logger attr_reader :thread_count, :logger
def initialize(file, thread_count) def initialize(file, thread_count)
......
...@@ -5,7 +5,6 @@ require 'zip' ...@@ -5,7 +5,6 @@ require 'zip'
namespace :import do namespace :import do
desc 'Import CSV' desc 'Import CSV'
task csv: :environment do task csv: :environment do
require "#{Rails.root}/lib/tasks/csv_reader"
thread_count = ENV['THREAD_COUNT'] || 1 thread_count = ENV['THREAD_COUNT'] || 1
ftp = Net::FTP.new ftp = Net::FTP.new
...@@ -28,7 +27,7 @@ namespace :import do ...@@ -28,7 +27,7 @@ namespace :import do
end end
end end
CSVReader.new(path_csv, thread_count).import Import::CSVReader.new(path_csv, thread_count).import
File.delete(path_zip) File.delete(path_zip)
File.delete(path_csv) File.delete(path_csv)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment