mirror of
https://github.com/Freika/dawarich.git
synced 2026-01-11 09:41:40 -05:00
20 lines
462 B
Ruby
20 lines
462 B
Ruby
# frozen_string_literal: true
|
|
|
|
class ReverseGeocodingJob < ApplicationJob
|
|
queue_as :reverse_geocoding
|
|
|
|
def perform(point_id)
|
|
return unless REVERSE_GEOCODING_ENABLED
|
|
|
|
point = Point.find(point_id)
|
|
return if point.city.present? && point.country.present?
|
|
|
|
result = Geocoder.search([point.latitude, point.longitude])
|
|
return if result.blank?
|
|
|
|
point.update(
|
|
city: result.first.city,
|
|
country: result.first.country
|
|
)
|
|
end
|
|
end
|