Sha256: b81163b9afc7f8d09f914c0de722ea3f21f4f1d3e056f32448faa01312723b0a
Contents?: true
Size: 928 Bytes
Versions: 1
Compression:
Stored size: 928 Bytes
Contents
module AuthTrail class GeocodeJob < ActiveJob::Base # default queue is used if queue_as returns nil # Rails has a test for this queue_as { AuthTrail.job_queue } def perform(login_activity) result = begin Geocoder.search(login_activity.ip).first rescue NameError # geocoder gem not installed raise rescue => e Rails.logger.info "Geocode failed: #{e.message}" nil end if result attributes = { city: result.try(:city), region: result.try(:state), country: result.try(:country), country_code: result.try(:country_code), latitude: result.try(:latitude), longitude: result.try(:longitude) } attributes.each do |k, v| login_activity.try("#{k}=", v.presence) end login_activity.save! end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
authtrail-0.4.0 | app/jobs/auth_trail/geocode_job.rb |