extinctionrebellion/RebelsManager

View on GitHub
app/jobs/geocode_rebel_job.rb

Summary

Maintainability
A
0 mins
Test Coverage
F
42%
class GeocodeRebelJob < ActiveJob::Base
  queue_as :default

  def perform(rebel)
    position = Geocoder.search("#{rebel.postcode}", params: { countrycodes: ENV['NOMINATIM_COUNTRY_CODE'] })&.first
    if !position.nil?
      rebel.update_column(:lat, position.data['lat']&.to_d)
      rebel.update_column(:lon, position.data['lon']&.to_d)
    end
  end
end