mirror of
https://github.com/Freika/dawarich.git
synced 2026-01-11 09:41:40 -05:00
Remove comments
This commit is contained in:
parent
2c82cb48a6
commit
9689b724d1
4 changed files with 23 additions and 30 deletions
|
|
@ -73,7 +73,6 @@ class User < ApplicationRecord # rubocop:disable Metrics/ClassLength
|
||||||
end
|
end
|
||||||
|
|
||||||
def total_reverse_geocoded_points
|
def total_reverse_geocoded_points
|
||||||
# Use cached count from StatsQuery instead of direct COUNT query
|
|
||||||
StatsQuery.new(self).points_stats[:geocoded]
|
StatsQuery.new(self).points_stats[:geocoded]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,6 @@ class StatsSerializer
|
||||||
end
|
end
|
||||||
|
|
||||||
def reverse_geocoded_points
|
def reverse_geocoded_points
|
||||||
# Use cached count from StatsQuery instead of direct COUNT query
|
|
||||||
StatsQuery.new(user).points_stats[:geocoded]
|
StatsQuery.new(user).points_stats[:geocoded]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,9 +9,6 @@ class CountriesAndCities
|
||||||
end
|
end
|
||||||
|
|
||||||
def call
|
def call
|
||||||
# Use attribute access directly to avoid N+1 on country association
|
|
||||||
# when country_name column is nil and Point#country_name method
|
|
||||||
# falls back to country&.name
|
|
||||||
points
|
points
|
||||||
.reject { |point| point[:country_name].nil? || point[:city].nil? }
|
.reject { |point| point[:country_name].nil? || point[:city].nil? }
|
||||||
.group_by { |point| point[:country_name] }
|
.group_by { |point| point[:country_name] }
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,6 @@ class ReverseGeocoding::Places::FetchData
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def find_place(place_data, existing_places)
|
def find_place(place_data, existing_places)
|
||||||
osm_id = place_data['properties']['osm_id'].to_s
|
osm_id = place_data['properties']['osm_id'].to_s
|
||||||
|
|
||||||
|
|
@ -82,9 +81,9 @@ class ReverseGeocoding::Places::FetchData
|
||||||
|
|
||||||
def find_existing_places(osm_ids)
|
def find_existing_places(osm_ids)
|
||||||
Place.where("geodata->'properties'->>'osm_id' IN (?)", osm_ids)
|
Place.where("geodata->'properties'->>'osm_id' IN (?)", osm_ids)
|
||||||
.global
|
.global
|
||||||
.index_by { |p| p.geodata.dig('properties', 'osm_id').to_s }
|
.index_by { |p| p.geodata.dig('properties', 'osm_id').to_s }
|
||||||
.compact
|
.compact
|
||||||
end
|
end
|
||||||
|
|
||||||
def prepare_places_for_bulk_operations(places, existing_places)
|
def prepare_places_for_bulk_operations(places, existing_places)
|
||||||
|
|
@ -114,9 +113,9 @@ class ReverseGeocoding::Places::FetchData
|
||||||
place.geodata = data
|
place.geodata = data
|
||||||
place.source = :photon
|
place.source = :photon
|
||||||
|
|
||||||
if place.lonlat.blank?
|
return if place.lonlat.present?
|
||||||
place.lonlat = build_point_coordinates(data['geometry']['coordinates'])
|
|
||||||
end
|
place.lonlat = build_point_coordinates(data['geometry']['coordinates'])
|
||||||
end
|
end
|
||||||
|
|
||||||
def save_places(places_to_create, places_to_update)
|
def save_places(places_to_create, places_to_update)
|
||||||
|
|
@ -138,24 +137,23 @@ class ReverseGeocoding::Places::FetchData
|
||||||
Place.insert_all(place_attributes)
|
Place.insert_all(place_attributes)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Batch update existing places to avoid N+1
|
return unless places_to_update.any?
|
||||||
if places_to_update.any?
|
|
||||||
update_attributes = places_to_update.map do |place|
|
update_attributes = places_to_update.map do |place|
|
||||||
{
|
{
|
||||||
id: place.id,
|
id: place.id,
|
||||||
name: place.name,
|
name: place.name,
|
||||||
latitude: place.latitude,
|
latitude: place.latitude,
|
||||||
longitude: place.longitude,
|
longitude: place.longitude,
|
||||||
lonlat: place.lonlat,
|
lonlat: place.lonlat,
|
||||||
city: place.city,
|
city: place.city,
|
||||||
country: place.country,
|
country: place.country,
|
||||||
geodata: place.geodata,
|
geodata: place.geodata,
|
||||||
source: place.source,
|
source: place.source,
|
||||||
updated_at: Time.current
|
updated_at: Time.current
|
||||||
}
|
}
|
||||||
end
|
|
||||||
Place.upsert_all(update_attributes, unique_by: :id)
|
|
||||||
end
|
end
|
||||||
|
Place.upsert_all(update_attributes, unique_by: :id)
|
||||||
end
|
end
|
||||||
|
|
||||||
def build_point_coordinates(coordinates)
|
def build_point_coordinates(coordinates)
|
||||||
|
|
@ -163,7 +161,7 @@ class ReverseGeocoding::Places::FetchData
|
||||||
end
|
end
|
||||||
|
|
||||||
def geocoder_places
|
def geocoder_places
|
||||||
data = Geocoder.search(
|
Geocoder.search(
|
||||||
[place.lat, place.lon],
|
[place.lat, place.lon],
|
||||||
limit: 10,
|
limit: 10,
|
||||||
distance_sort: true,
|
distance_sort: true,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue