]> git.openstreetmap.org Git - rails.git/commitdiff
Add a configuration flag for using the job queue to import traces
authorAndy Allan <git@gravitystorm.co.uk>
Wed, 16 Jan 2019 10:13:55 +0000 (11:13 +0100)
committerAndy Allan <git@gravitystorm.co.uk>
Wed, 16 Jan 2019 10:13:55 +0000 (11:13 +0100)
This will allow the code to be merged to master, even if osm.org
isn't ready to start using it yet.

app/controllers/traces_controller.rb
config/example.application.yml

index d06c05b2064ab9514bf96d8f8d333188ee7cfff0..2e499787788373c7f209fc75970b63d52a07e4e6 100644 (file)
@@ -127,7 +127,7 @@ class TracesController < ApplicationController
         flash[:notice] = t ".trace_uploaded"
         flash[:warning] = t ".traces_waiting", :count => current_user.traces.where(:inserted => false).count if current_user.traces.where(:inserted => false).count > 4
 
         flash[:notice] = t ".trace_uploaded"
         flash[:warning] = t ".traces_waiting", :count => current_user.traces.where(:inserted => false).count if current_user.traces.where(:inserted => false).count > 4
 
-        TraceImporterJob.perform_later(@trace)
+        TraceImporterJob.perform_later(@trace) if TRACE_USE_JOB_QUEUE
         redirect_to :action => :index, :display_name => current_user.display_name
       else
         flash[:error] = t("traces.create.upload_failed") if @trace.valid?
         redirect_to :action => :index, :display_name => current_user.display_name
       else
         flash[:error] = t("traces.create.upload_failed") if @trace.valid?
@@ -211,7 +211,7 @@ class TracesController < ApplicationController
       trace.visible = false
       trace.save
       flash[:notice] = t ".scheduled_for_deletion"
       trace.visible = false
       trace.save
       flash[:notice] = t ".scheduled_for_deletion"
-      TraceDestroyerJob.perform_later(trace)
+      TraceDestroyerJob.perform_later(trace) if TRACE_USE_JOB_QUEUE
       redirect_to :action => :index, :display_name => trace.user.display_name
     end
   rescue ActiveRecord::RecordNotFound
       redirect_to :action => :index, :display_name => trace.user.display_name
     end
   rescue ActiveRecord::RecordNotFound
index b6884825b5c68f137a368a16053f68300a692bf3..b0b468d9ee07b1f6044f05295a5034effc52975b 100644 (file)
@@ -60,6 +60,10 @@ defaults: &defaults
   spam_threshold: 50
   # Default legale (jurisdiction location) for contributor terms
   default_legale: GB
   spam_threshold: 50
   # Default legale (jurisdiction location) for contributor terms
   default_legale: GB
+  # Use the built-in jobs queue for importing traces
+  # Leave as false if you are using the external high-speed gpx importer
+  # https://github.com/openstreetmap/gpx-import
+  trace_use_job_queue: false
   # Location of GPX traces and images
   gpx_trace_dir: "/home/osm/traces"
   gpx_image_dir: "/home/osm/images"
   # Location of GPX traces and images
   gpx_trace_dir: "/home/osm/traces"
   gpx_image_dir: "/home/osm/images"