mirror of
https://github.com/edcommonwealth/sqm-dashboards.git
synced 2026-03-07 21:48:16 -08:00
Reduce number of rows to process to avoid exceeding memory limit on heroku
This commit is contained in:
parent
0321b3d43f
commit
bb472ce6c3
1 changed files with 2 additions and 2 deletions
|
|
@ -7,12 +7,12 @@ class SurveyResponsesDataLoader
|
|||
File.open(filepath) do |file|
|
||||
headers = file.first
|
||||
|
||||
file.lazy.each_slice(1000) do |lines|
|
||||
file.lazy.each_slice(500) do |lines|
|
||||
survey_item_responses = CSV.parse(lines.join, headers:).map do |row|
|
||||
process_row row: Values.new(row:, headers:)
|
||||
end
|
||||
|
||||
SurveyItemResponse.import survey_item_responses.compact.flatten, batch_size: 1000
|
||||
SurveyItemResponse.import survey_item_responses.compact.flatten, batch_size: 500
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue