geotag_worker.rb 561 B

12345678910111213141516171819202122232425262728
  1. class GeotagWorker
  2. include Sidekiq::Worker
  3. sidekiq_options :retry => true, :backtrace => true #, expires_in: 1.day
  4. def perform(id)
  5. record = PhoneLead.find(id)
  6. identifier = Phonelib.parse (record.number)
  7. begin
  8. state = Integer(record.area_code).to_region
  9. if state
  10. record.location = state
  11. end
  12. rescue
  13. # Ignore
  14. end
  15. if identifier
  16. record.number_type = identifier.human_type
  17. record.country = identifier.country
  18. record.state ||= identifier.geo_name
  19. end
  20. record.save
  21. end
  22. end