Skip to content

Instantly share code, notes, and snippets.

@Chocksy
Last active April 23, 2020 14:27
Show Gist options
  • Save Chocksy/27fc38dee31810f6eca0289690e4a530 to your computer and use it in GitHub Desktop.
Save Chocksy/27fc38dee31810f6eca0289690e4a530 to your computer and use it in GitHub Desktop.
Process ahoy visits geocode information. We can use this to retry previous visits that have no location data.
# Get all visits that have `ip` set and no `country`, `city`, `latitude` & `longitude` set.
# Schedule background jobs to process each visit and update it.
Visit.where.not(ip: nil).where(country: nil, city: nil, latitude: nil, longitude: nil).find_each { |visit| Ahoy::GeocodeJob.set(queue: Ahoy.job_queue).perform_later(visit) }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment