Sha256: 353aedc3ceae4d9ecff388b6356376272a3b7a1e31045777e3739d45eaf5a62e

Contents?: true

Size: 510 Bytes

Versions: 2

Compression:

Stored size: 510 Bytes

Contents

module AuthTrail
  class GeocodeJob < ApplicationJob
    def perform(login_activity)
      result =
        begin
          Geocoder.search(login_activity.ip).first.try(:data)
        rescue => e
          Rails.logger.info "Geocode failed: #{e.message}"
          nil
        end

      if result
        login_activity.update!(
          city: result["city"].presence,
          region: result["region_name"].presence,
          country: result["country_name"].presence
        )
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
authtrail-0.1.1 app/jobs/auth_trail/geocode_job.rb
authtrail-0.1.0 app/jobs/auth_trail/geocode_job.rb