Sha256: bceca9aa22c8bd335c76557767c7ed9c6300cc368c6b3a78f0e22b2cc4530cea

Contents?: true

Size: 497 Bytes

Versions: 1

Compression:

Stored size: 497 Bytes

Contents

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

      if result
        login_activity.update!(
          city: result.try(:city).presence,
          region: result.try(:state).presence,
          country: result.try(:country).presence
        )
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
authtrail-0.1.2 app/jobs/auth_trail/geocode_job.rb