feat: add command for loading survey responses from arbitrary sftp directory

This commit is contained in:
rebuilt 2023-10-30 19:44:52 -07:00
parent e3fbbabce5
commit 2d90516f9f
2 changed files with 37 additions and 6 deletions

View file

@ -17,6 +17,24 @@ namespace :data do
Rails.cache.clear
end
desc "load survey responses from a specific directory"
task load_survey_responses_from_path: :environment do
survey_item_response_count = SurveyItemResponse.count
student_count = Student.count
path = "#{ENV['SFTP_PATH']}"
Sftp::Directory.open(path:) do |file|
SurveyResponsesDataLoader.new.from_file(file:)
end
puts "=====================> Completed loading #{SurveyItemResponse.count - survey_item_response_count} survey responses. #{SurveyItemResponse.count} total responses in the database"
Sftp::Directory.open(path:) do |file|
StudentLoader.from_file(file:, rules: [])
end
puts "=====================> Completed loading #{Student.count - student_count} students. #{Student.count} total students"
Rails.cache.clear
end
desc "load admin_data"
task load_admin_data: :environment do
original_count = AdminDataValue.count