mirror of
https://github.com/Freika/dawarich.git
synced 2026-01-10 01:01:39 -05:00
Move setting reverse_geocoded_at to background job
This commit is contained in:
parent
5e3f5a76ff
commit
3554e405db
4 changed files with 25 additions and 4 deletions
|
|
@ -1 +1 @@
|
|||
0.20.0
|
||||
0.20.1
|
||||
|
|
|
|||
|
|
@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
|
|||
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
||||
and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
# 0.20.1 - 2024-12-16
|
||||
|
||||
### Fixed
|
||||
|
||||
- Setting `reverse_geocoded_at` for points that don't have geodata is now being performed in background job, in batches of 10,000 points to prevent memory exhaustion.
|
||||
|
||||
# 0.20.0 - 2024-12-16
|
||||
|
||||
### Added
|
||||
|
|
|
|||
|
|
@ -0,0 +1,17 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class DataMigrations::SetReverseGeocodedAtForPointsJob < ApplicationJob
|
||||
queue_as :default
|
||||
|
||||
def perform
|
||||
timestamp = Time.current
|
||||
|
||||
Point.where.not(geodata: {})
|
||||
.where(reverse_geocoded_at: nil)
|
||||
.in_batches(of: 10_000) do |relation|
|
||||
# rubocop:disable Rails/SkipsModelValidations
|
||||
relation.update_all(reverse_geocoded_at: timestamp)
|
||||
# rubocop:enable Rails/SkipsModelValidations
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -2,9 +2,7 @@
|
|||
|
||||
class SetReverseGeocodedAtForPoints < ActiveRecord::Migration[7.2]
|
||||
def up
|
||||
# rubocop:disable Rails/SkipsModelValidations
|
||||
Point.where.not(geodata: {}).update_all(reverse_geocoded_at: Time.current)
|
||||
# rubocop:enable Rails/SkipsModelValidations
|
||||
DataMigrations::SetReverseGeocodedAtForPointsJob.perform_later
|
||||
end
|
||||
|
||||
def down
|
||||
|
|
|
|||
Loading…
Reference in a new issue