mirror of
https://github.com/edcommonwealth/sqm-dashboards.git
synced 2026-03-07 21:48:16 -08:00
fix: ensure loaded survey item responses are uniq by id to avoid PG::CardinalityViolation: ERROR: ON CONFLICT DO UPDATE command cannot affect row a second time (PG::CardinalityViolation)
This commit is contained in:
parent
1da1b238e0
commit
a3082037fa
1 changed files with 5 additions and 1 deletions
|
|
@ -43,7 +43,11 @@ class SurveyResponsesDataLoader
|
|||
row_count += 1
|
||||
next unless row_count == batch_size
|
||||
|
||||
SurveyItemResponse.import(survey_item_responses.compact.flatten, batch_size:, on_duplicate_key_update: :all)
|
||||
survey_item_responses = survey_item_responses.compact.flatten.uniq do |response|
|
||||
response.response_id
|
||||
end
|
||||
|
||||
SurveyItemResponse.import(survey_item_responses, batch_size:, on_duplicate_key_update: :all)
|
||||
survey_item_responses = [] unless file.eof?
|
||||
GC.start
|
||||
row_count = 0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue