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
|
||||
|
||||
def total_reverse_geocoded_points
|
||||
# Use cached count from StatsQuery instead of direct COUNT query
|
||||
StatsQuery.new(self).points_stats[:geocoded]
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@ class StatsSerializer
|
|||
end
|
||||
|
||||
def reverse_geocoded_points
|
||||
# Use cached count from StatsQuery instead of direct COUNT query
|
||||
StatsQuery.new(user).points_stats[:geocoded]
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -9,9 +9,6 @@ class CountriesAndCities
|
|||
end
|
||||
|
||||
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
|
||||
.reject { |point| point[:country_name].nil? || point[:city].nil? }
|
||||
.group_by { |point| point[:country_name] }
|
||||
|
|
|
|||
|
|
@ -48,7 +48,6 @@ class ReverseGeocoding::Places::FetchData
|
|||
)
|
||||
end
|
||||
|
||||
|
||||
def find_place(place_data, existing_places)
|
||||
osm_id = place_data['properties']['osm_id'].to_s
|
||||
|
||||
|
|
@ -114,10 +113,10 @@ class ReverseGeocoding::Places::FetchData
|
|||
place.geodata = data
|
||||
place.source = :photon
|
||||
|
||||
if place.lonlat.blank?
|
||||
return if place.lonlat.present?
|
||||
|
||||
place.lonlat = build_point_coordinates(data['geometry']['coordinates'])
|
||||
end
|
||||
end
|
||||
|
||||
def save_places(places_to_create, places_to_update)
|
||||
if places_to_create.any?
|
||||
|
|
@ -138,8 +137,8 @@ class ReverseGeocoding::Places::FetchData
|
|||
Place.insert_all(place_attributes)
|
||||
end
|
||||
|
||||
# Batch update existing places to avoid N+1
|
||||
if places_to_update.any?
|
||||
return unless places_to_update.any?
|
||||
|
||||
update_attributes = places_to_update.map do |place|
|
||||
{
|
||||
id: place.id,
|
||||
|
|
@ -156,14 +155,13 @@ class ReverseGeocoding::Places::FetchData
|
|||
end
|
||||
Place.upsert_all(update_attributes, unique_by: :id)
|
||||
end
|
||||
end
|
||||
|
||||
def build_point_coordinates(coordinates)
|
||||
"POINT(#{coordinates[0]} #{coordinates[1]})"
|
||||
end
|
||||
|
||||
def geocoder_places
|
||||
data = Geocoder.search(
|
||||
Geocoder.search(
|
||||
[place.lat, place.lon],
|
||||
limit: 10,
|
||||
distance_sort: true,
|
||||
|
|
|
|||
Loading…
Reference in a new issue