mirror of
https://github.com/edcommonwealth/Dashboard.git
synced 2026-03-16 17:45:53 -07:00
chore: load survey item responses. Show overview page without server errors
This commit is contained in:
parent
589c0f7e11
commit
a538eb72f2
9 changed files with 94 additions and 87 deletions
|
|
@ -1,33 +1,35 @@
|
|||
require 'net/sftp'
|
||||
require 'uri'
|
||||
require 'csv'
|
||||
require "net/sftp"
|
||||
require "uri"
|
||||
require "csv"
|
||||
|
||||
module Sftp
|
||||
class RaceLoader
|
||||
def self.load_data(path: '/data/survey_responses/')
|
||||
SurveyItemResponse.update_all(student_id: nil)
|
||||
StudentRace.delete_all
|
||||
Student.delete_all
|
||||
module Dashboard
|
||||
module Sftp
|
||||
class RaceLoader
|
||||
def self.load_data(path: "/data/survey_responses/")
|
||||
SurveyItemResponse.update_all(student_id: nil)
|
||||
StudentRace.delete_all
|
||||
Student.delete_all
|
||||
|
||||
sftptogo_url = ENV['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|
|
||||
filename = entry.name
|
||||
puts filename
|
||||
sftptogo_url = ENV["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|
|
||||
filename = entry.name
|
||||
puts filename
|
||||
|
||||
sftp.file.open(filepath(path:, filename:), 'r') do |f|
|
||||
StudentLoader.from_file(file: f, rules: [Rule::SkipNonLowellSchools])
|
||||
sftp.file.open(filepath(path:, filename:), "r") do |f|
|
||||
StudentLoader.from_file(file: f, rules: [Rule::SkipNonLowellSchools])
|
||||
end
|
||||
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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue