From 045999b29296933f2d99f7b19879fb56aaadd98a Mon Sep 17 00:00:00 2001 From: Eugene Burmakin Date: Mon, 10 Jun 2024 22:37:32 +0200 Subject: [PATCH] Add migration to remove points without coordinates --- config/sidekiq.yml | 2 +- ...70930_remove_points_without_coordinates.rb | 19 +++++++++++++++++++ db/data_schema.rb | 2 +- 3 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 db/data/20240610170930_remove_points_without_coordinates.rb diff --git a/config/sidekiq.yml b/config/sidekiq.yml index 9b4e59d4..a073af8b 100644 --- a/config/sidekiq.yml +++ b/config/sidekiq.yml @@ -1,5 +1,5 @@ --- -:concurrency: <%= ENV.fetch("BACKGROUND_PROCESSING_CONCURRENCY", 100) %> +:concurrency: <%= ENV.fetch("BACKGROUND_PROCESSING_CONCURRENCY", 10) %> :queues: - default - imports diff --git a/db/data/20240610170930_remove_points_without_coordinates.rb b/db/data/20240610170930_remove_points_without_coordinates.rb new file mode 100644 index 00000000..2052f72e --- /dev/null +++ b/db/data/20240610170930_remove_points_without_coordinates.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +class RemovePointsWithoutCoordinates < ActiveRecord::Migration[7.1] + def up + points = Point.where('longitude = 0.0 OR latitude = 0.0') + + Rails.logger.info "Found #{points.count} points without coordinates..." + + points + .select { |point| point.raw_data['latitudeE7'].nil? && point.raw_data['longitudeE7'].nil? } + .each(&:destroy) + + Rails.logger.info 'Points without coordinates removed.' + end + + def down + raise ActiveRecord::IrreversibleMigration + end +end diff --git a/db/data_schema.rb b/db/data_schema.rb index 394d4c85..14d36074 100644 --- a/db/data_schema.rb +++ b/db/data_schema.rb @@ -1 +1 @@ -DataMigrate::Data.define(version: 20240525110530) +DataMigrate::Data.define(version: 20240610170930)