mirror of
https://github.com/Freika/dawarich.git
synced 2026-01-11 09:41:40 -05:00
Update the rake task to also reindex the points table.
This commit is contained in:
parent
24a148b181
commit
5335c912c3
3 changed files with 21 additions and 10 deletions
|
|
@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||||
## Fixed
|
## Fixed
|
||||||
|
|
||||||
- Moving points on the map now works correctly. #957
|
- Moving points on the map now works correctly. #957
|
||||||
|
- `rake points:migrate_to_lonlat` task now also reindexes the points table.
|
||||||
|
|
||||||
# 0.25.3 - 2025-03-22
|
# 0.25.3 - 2025-03-22
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<div class="w-full mx-auto my-5">
|
<div class="w-full mx-auto my-5">
|
||||||
<div class="flex justify-between items-center mt-5 mb-5">
|
<div class="flex justify-between items-center mt-5 mb-5">
|
||||||
<div class="hero h-fit bg-base-200 py-20" style="background-image: url(<%= '/images/bg-image.jpg' %>);">
|
<div class="hero h-fit bg-base-200 py-20">
|
||||||
<div class="hero-content text-center">
|
<div class="hero-content text-center">
|
||||||
<div class="max-w-md">
|
<div class="max-w-md">
|
||||||
<h1 class="text-5xl font-bold">
|
<h1 class="text-5xl font-bold">
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,12 @@ namespace :points do
|
||||||
task migrate_to_lonlat: :environment do
|
task migrate_to_lonlat: :environment do
|
||||||
puts 'Updating points to use lonlat...'
|
puts 'Updating points to use lonlat...'
|
||||||
|
|
||||||
# Use PostGIS functions to properly create geography type
|
ActiveRecord::Base.connection.execute('REINDEX TABLE points;')
|
||||||
|
|
||||||
|
ActiveRecord::Base.transaction do
|
||||||
|
ActiveRecord::Base.connection.execute('ALTER TABLE points DISABLE TRIGGER ALL;')
|
||||||
|
|
||||||
|
# Update the data
|
||||||
result = ActiveRecord::Base.connection.execute(<<~SQL)
|
result = ActiveRecord::Base.connection.execute(<<~SQL)
|
||||||
UPDATE points
|
UPDATE points
|
||||||
SET lonlat = ST_SetSRID(ST_MakePoint(longitude, latitude), 4326)::geography
|
SET lonlat = ST_SetSRID(ST_MakePoint(longitude, latitude), 4326)::geography
|
||||||
|
|
@ -14,6 +19,11 @@ namespace :points do
|
||||||
AND latitude IS NOT NULL;
|
AND latitude IS NOT NULL;
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
|
ActiveRecord::Base.connection.execute('ALTER TABLE points ENABLE TRIGGER ALL;')
|
||||||
|
|
||||||
puts "Successfully updated #{result.cmd_tuples} points with lonlat values"
|
puts "Successfully updated #{result.cmd_tuples} points with lonlat values"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
ActiveRecord::Base.connection.execute('ANALYZE points;')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue