Fixed front page on mobile and improved city lookup

This commit is contained in:
Godwin
2016-12-13 22:29:57 -08:00
parent 868f21a5f7
commit e83c2fc464
8 changed files with 440 additions and 307 deletions
+25 -7
View File
@@ -24,15 +24,25 @@ end
task update_cities: :environment do
Location.all.each do |l|
city = City.search(([l.city, l.territory, l.country] - [nil, '']).join(', '))
l.city_id = city.id
l.save!
s = ([l.city, l.territory, l.country] - [nil, '']).join(', ')
unless l.city_id.present?
begin
puts "Searching for #{s}"
city = City.search(s)
l.city_id = city.id
l.save!
rescue
puts "Error searching for #{s}"
end
end
end
City.all.each do |c|
location = Geocoder.search(c.address, language: 'en').first
c.place_id = location.data['place_id']
c.save!
unless c.place_id.present?
City.all.each do |c|
location = Geocoder.search(c.address, language: 'en').first
c.place_id = location.data['place_id']
c.save!
end
end
end
@@ -43,3 +53,11 @@ task update_cities_es: :environment do
c.save!
end
end
task update_cities_fr: :environment do
City.all.each do |c|
city = c.get_translation(:fr)
c.set_column_for_locale(:city, :fr, city, 0) unless city.blank? || city == c.get_column_for_locale(:city, :fr)
c.save!
end
end