diff --git a/lib/etl/transformers/async/ultrasignup_historical_facts_strategy.rb b/lib/etl/transformers/async/ultrasignup_historical_facts_strategy.rb index 717a5fc85..4fb29e598 100644 --- a/lib/etl/transformers/async/ultrasignup_historical_facts_strategy.rb +++ b/lib/etl/transformers/async/ultrasignup_historical_facts_strategy.rb @@ -62,7 +62,7 @@ def record_volunteer_reported(struct) if years_count.present? && years_count.positive? proto_record = base_proto_record.deep_dup - proto_record[:kind] = :volunteer_multi + proto_record[:kind] = :volunteer_multi_reported proto_record[:quantity] = years_count proto_record[:comments] = struct[:Volunteer_description] diff --git a/lib/tasks/temp/historical_facts_fix_vmulti_duplicates.rake b/lib/tasks/temp/historical_facts_fix_vmulti_duplicates.rake new file mode 100644 index 000000000..25ccf156c --- /dev/null +++ b/lib/tasks/temp/historical_facts_fix_vmulti_duplicates.rake @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +namespace :temp do + desc "Changes imported volunteer_multi records to volunteer_multi_reported" + task historical_facts_fix_vmulti_duplicates: :environment do + puts "Changing volunteer_multi records to volunteer_multi_reported" + + historical_facts = HistoricalFact.where(kind: :volunteer_multi, year: 2024) + hf_count = historical_facts.count + + puts "Found #{hf_count} historical facts to update" + + progress_bar = ::ProgressBar.new(hf_count) + + historical_facts.find_each do |fact| + progress_bar.increment! + fact.update(kind: :volunteer_multi_reported) + rescue ActiveRecordError => e + puts "Could not update record for HistoricalFact id: #{fact.id}" + puts e + end + end +end diff --git a/spec/lib/etl/transformers/async/ultrasignup_historical_facts_strategy_spec.rb b/spec/lib/etl/transformers/async/ultrasignup_historical_facts_strategy_spec.rb index 4d6b1863d..0b98cb70f 100644 --- a/spec/lib/etl/transformers/async/ultrasignup_historical_facts_strategy_spec.rb +++ b/spec/lib/etl/transformers/async/ultrasignup_historical_facts_strategy_spec.rb @@ -134,7 +134,7 @@ end it "returns one proto_record for each multi-year volunteer fact" do - volunteer_multi_proto_records = proto_records.select { |proto_record| proto_record.attributes[:kind] == :volunteer_multi } + volunteer_multi_proto_records = proto_records.select { |proto_record| proto_record.attributes[:kind] == :volunteer_multi_reported } expect(volunteer_multi_proto_records.count).to eq(1) proto_record = volunteer_multi_proto_records.first expect(proto_record[:quantity]).to eq(3)