diff --git a/Gemfile b/Gemfile index 27f295eb65..a916fb6045 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 a00f0fc0ad..3c5d13b3c9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -65,8 +65,6 @@ GEM activemodel (= 7.1.4) activesupport (= 7.1.4) timeout (>= 0.4.0) - activerecord-import (1.8.1) - activerecord (>= 4.2) activestorage (7.1.4) actionpack (= 7.1.4) activejob (= 7.1.4) @@ -614,7 +612,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 20723b98d0..3b35b76961 100644 --- a/app/models/trace.rb +++ b/app/models/trace.rb @@ -230,16 +230,17 @@ def import tp.timestamp = point.timestamp tp.gpx_id = id tp.trackid = point.segment + tp.validate! 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)) # rubocop:disable Rails::SkipsModelValidations end if gpx.actual_points.positive?