Fix missing var

This commit is contained in:
Eugene Burmakin 2025-09-03 20:05:03 +02:00
parent 689b8cb0f1
commit 2b1f6d66bc

View file

@ -33,12 +33,8 @@ module LocationSearch
end
def normalize_geocoding_results(results)
normalized_results = []
results.each do |result|
next unless valid_result?(result)
normalized_result = {
normalized_results = results.map do |result|
{
lat: result.latitude.to_f,
lon: result.longitude.to_f,
name: result.address&.split(',')&.first || 'Unknown location',
@ -50,22 +46,11 @@ module LocationSearch
importance: result.data&.dig('importance')
}
}
normalized_results << normalized_result
end
deduplicate_results(normalized_results)
end
def valid_result?(result)
result.present? &&
result.latitude.present? &&
result.longitude.present? &&
result.latitude.to_f.abs <= 90 &&
result.longitude.to_f.abs <= 180
end
def deduplicate_results(results)
deduplicated = []