mirror of
https://github.com/edcommonwealth/sqm-dashboards.git
synced 2026-03-07 21:48:16 -08:00
chore: rename sftp environment variable
This commit is contained in:
parent
623dbe5e44
commit
1c4cec3fed
2 changed files with 51 additions and 5 deletions
|
|
@ -4,8 +4,8 @@ require 'uri'
|
|||
module Sftp
|
||||
class Directory
|
||||
def self.open(path: '/data/survey_responses/clean', &block)
|
||||
sftptogo_url = ENV['SFTPTOGO_URL']
|
||||
uri = URI.parse(sftptogo_url)
|
||||
sftp_url = ENV['SFTP_URL']
|
||||
uri = URI.parse(sftp_url)
|
||||
Net::SFTP.start(uri.host, uri.user, password: uri.password) do |sftp|
|
||||
sftp.dir.foreach(path) do |entry|
|
||||
next unless entry.file?
|
||||
|
|
|
|||
|
|
@ -7,8 +7,8 @@ namespace :upload do
|
|||
next if filename.start_with?('.') # skip hidden files and ./.. directories
|
||||
# this can probably be replaced with Dir.join or similar
|
||||
input_filename = Rails.root.join('tmp', 'data', 'rpp_data', 'clean', filename).to_s
|
||||
sftptogo_url = ENV['SFTPTOGO_URL']
|
||||
uri = URI.parse(sftptogo_url)
|
||||
sftp_url = ENV['SFTP_URL']
|
||||
uri = URI.parse(sftp_url)
|
||||
Net::SFTP.start(uri.host, uri.user, password: uri.password) do |sftp|
|
||||
puts "Uploading #{filename}..."
|
||||
sftp.upload!(input_filename, "/data/survey_responses/clean/#{filename}")
|
||||
|
|
@ -21,4 +21,50 @@ namespace :upload do
|
|||
# the open method already prints all the contents...
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
desc 'upload cleaned ECP CSVs to the SFTP server'
|
||||
task ecp: :environment do
|
||||
new_files = Array.new
|
||||
input_filepath = Rails.root.join('tmp', 'data', 'ecp_data', 'clean')
|
||||
Dir.foreach(input_filepath) do |filename|
|
||||
next if filename.start_with?('.') # skip hidden files and ./.. directories
|
||||
# this can probably be replaced with Dir.join or similar
|
||||
input_filename = Rails.root.join('tmp', 'data', 'ecp_data', 'clean', filename).to_s
|
||||
sftp_url = ENV['SFTP_URL']
|
||||
uri = URI.parse(sftp_url)
|
||||
Net::SFTP.start(uri.host, uri.user, password: uri.password) do |sftp|
|
||||
puts "Uploading #{filename}..."
|
||||
sftp.upload!(input_filename, "/data/survey_responses/clean/#{filename}")
|
||||
end
|
||||
new_files.append(filename)
|
||||
end
|
||||
# print remote directory contents with new files marked
|
||||
path = '/data/survey_responses/clean/'
|
||||
Sftp::Directory.open(path:) do |file|
|
||||
# the open method already prints all the contents...
|
||||
end
|
||||
end
|
||||
|
||||
desc 'upload cleaned MCIEA CSVs to the SFTP server'
|
||||
task mciea: :environment do
|
||||
new_files = Array.new
|
||||
input_filepath = Rails.root.join('tmp', 'data', 'mciea_data', 'clean')
|
||||
Dir.foreach(input_filepath) do |filename|
|
||||
next if filename.start_with?('.') # skip hidden files and ./.. directories
|
||||
# this can probably be replaced with Dir.join or similar
|
||||
input_filename = Rails.root.join('tmp', 'data', 'mciea_data', 'clean', filename).to_s
|
||||
sftp_url = ENV['SFTP_URL']
|
||||
uri = URI.parse(sftp_url)
|
||||
Net::SFTP.start(uri.host, uri.user, password: uri.password) do |sftp|
|
||||
puts "Uploading #{filename}..."
|
||||
sftp.upload!(input_filename, "/data/survey_responses/clean/#{filename}")
|
||||
end
|
||||
new_files.append(filename)
|
||||
end
|
||||
# print remote directory contents with new files marked
|
||||
path = '/data/survey_responses/clean/'
|
||||
Sftp::Directory.open(path:) do |file|
|
||||
# the open method already prints all the contents...
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue