lib/tasks/fix_maine_nil_counties.rake
def pull_county
      puts("Beginning pull counties")
      file_name = "#{Rails.root}/list_county.csv"
      total_count = people.count
      users_per_iteration = 10_000.0
      counter = 0
      number_of_iterations = (total_count / users_per_iteration).ceil
      CSV.open(file_name, 'w+', headers: true) do |csv|
        csv << ["person_hbx_id", "zip"]
        while counter < number_of_iterations
          offset_count = users_per_iteration * counter
          output = people.no_timeout.offset(offset_count).each do |person|
            address = person.rating_address
            county = address&.county
            csv << [person.hbx_id, address&.zip] if county.nil?
            counter += 1
          end
        end
      end
    end
#1 list people with nil county
1 list people with nil county
1 list people with nil county
def pull_county
      puts("Beginning pull counties")
      file_name = "#{Rails.root}/list_county.csv"
      total_count = people.count
      users_per_iteration = 10_000.0
      counter = 0
      number_of_iterations = (total_count / users_per_iteration).ceil
      CSV.open(file_name, 'w+', headers: true) do |csv|
        csv << ["person_hbx_id", "zip"]
        while counter < number_of_iterations
          offset_count = users_per_iteration * counter
          output = people.no_timeout.offset(offset_count).each do |person|
            address = person.rating_address
            county = address&.county
            csv << [person.hbx_id, address&.zip] if county.nil?
            counter += 1
          end
        end
      end
    end
def pull_county puts ( "Beginning pull counties" ) file_name = "#{Rails.root}/list_county.csv" total_count = people . count users_per_iteration = 10_000.0 counter = 0 number_of_iterations = ( total_count / users_per_iteration ) . ceil CSV . open ( file_name , 'w+' , headers : true ) do | csv | csv << [ "person_hbx_id" , "zip" ] while counter < number_of_iterations offset_count = users_per_iteration * counter output = people . no_timeout . offset ( offset_count ) . each do | person | address = person . rating_address county = address &. county csv << [ person . hbx_id , address &. zip ] if county . nil? counter += 1 end end end end
1 list people with nil county
1 list people with nil county