]> git.openstreetmap.org Git - rails.git/blob - app/jobs/trace_importer_job.rb
Removed unused translations in user_role namespace
[rails.git] / app / jobs / trace_importer_job.rb
1 class TraceImporterJob < ApplicationJob
2   queue_as :traces
3
4   def perform(trace)
5     gpx = trace.import
6
7     if gpx.actual_points.positive?
8       UserMailer.gpx_success(trace, gpx.actual_points).deliver
9     else
10       UserMailer.gpx_failure(trace, "0 points parsed ok. Do they all have lat,lng,alt,timestamp?").deliver
11       trace.destroy
12     end
13   rescue StandardError => e
14     logger.info e.to_s
15     e.backtrace.each { |l| logger.info l }
16     UserMailer.gpx_failure(trace, "#{e}\n#{e.backtrace.join("\n")}").deliver
17     trace.destroy
18   end
19 end