chore: load survey item responses. Show overview page without server errors

This commit is contained in:
Nelson Jovel 2024-01-26 07:43:29 -08:00
parent 589c0f7e11
commit a538eb72f2
9 changed files with 94 additions and 87 deletions

View file

@ -1,29 +1,31 @@
require 'net/sftp'
require 'uri'
require 'csv'
require "net/sftp"
require "uri"
require "csv"
module Sftp
class Directory
def self.open(path: '/data/survey_responses/clean', &block)
sftptogo_url = ENV['MCIEA_SFTPTOGO_URL']
uri = URI.parse(sftptogo_url)
Net::SFTP.start(uri.host, uri.user, password: uri.password) do |sftp|
sftp.dir.foreach(path) do |entry|
next unless entry.file?
module Dashboard
module Sftp
class Directory
def self.open(path: "/data/survey_responses/clean", &block)
sftptogo_url = ENV["ECP_SFTPTOGO_URL"]
uri = URI.parse(sftptogo_url)
Net::SFTP.start(uri.host, uri.user, password: uri.password) do |sftp|
sftp.dir.foreach(path) do |entry|
next unless entry.file?
filename = entry.name
puts filename
filename = entry.name
puts filename
sftp.file.open(filepath(path:, filename:), 'r', &block)
sftp.file.open(filepath(path:, filename:), "r", &block)
end
end
end
end
def self.filepath(path:, filename:)
path += '/' unless path.end_with?('/')
"#{path}#{filename}"
end
def self.filepath(path:, filename:)
path += "/" unless path.end_with?("/")
"#{path}#{filename}"
end
private_class_method :filepath
private_class_method :filepath
end
end
end