From 5733e21f12c86b6a6082e70cfb78c98ac2edd48b Mon Sep 17 00:00:00 2001 From: mmd-osm Date: Thu, 1 Aug 2024 20:06:13 +0200 Subject: [PATCH] Trace import: remove activerecord-import gem Fixes #4994 --- .rubocop.yml | 1 + Gemfile | 1 - Gemfile.lock | 3 --- app/models/trace.rb | 4 ++-- 4 files changed, 3 insertions(+), 6 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index c0f0c1fa080..1ac40071443 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -71,6 +71,7 @@ Rails/SkipsModelValidations: Exclude: - 'db/migrate/*.rb' - 'app/controllers/users_controller.rb' + - 'app/models/trace.rb' Style/Documentation: Enabled: false diff --git a/Gemfile b/Gemfile index fcf2ceb4d1d..5095f313d3e 100644 --- a/Gemfile +++ b/Gemfile @@ -48,7 +48,6 @@ gem "file_exists" # Load rails plugins gem "actionpack-page_caching", ">= 1.2.0" -gem "activerecord-import" gem "active_record_union" gem "bootstrap", "~> 5.3.2" gem "bootstrap_form", "~> 5.0" diff --git a/Gemfile.lock b/Gemfile.lock index e1337f6a46a..5307f6043bb 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -65,8 +65,6 @@ GEM activemodel (= 7.1.3.4) activesupport (= 7.1.3.4) timeout (>= 0.4.0) - activerecord-import (1.7.0) - activerecord (>= 4.2) activestorage (7.1.3.4) actionpack (= 7.1.3.4) activejob (= 7.1.3.4) @@ -606,7 +604,6 @@ DEPENDENCIES aasm actionpack-page_caching (>= 1.2.0) active_record_union - activerecord-import addressable (~> 2.8) annotate argon2 diff --git a/app/models/trace.rb b/app/models/trace.rb index 20723b98d01..a560b4d4ccb 100644 --- a/app/models/trace.rb +++ b/app/models/trace.rb @@ -233,13 +233,13 @@ def import tracepoints << tp end - # Run the before_save and before_create callbacks, and then import them in bulk with activerecord-import + # Run the before_save and before_create callbacks, and then do a bulk insert tracepoints.each do |tp| tp.run_callbacks(:save) { false } tp.run_callbacks(:create) { false } end - Tracepoint.import!(tracepoints) + Tracepoint.insert_all!(tracepoints.map(&:attributes)) end if gpx.actual_points.positive?