]> git.openstreetmap.org Git - rails.git/commitdiff
Preload traces for the selected points
authorAndy Allan <git@gravitystorm.co.uk>
Wed, 11 Nov 2020 17:52:33 +0000 (17:52 +0000)
committerAndy Allan <git@gravitystorm.co.uk>
Wed, 11 Nov 2020 17:52:33 +0000 (17:52 +0000)
It doesn't make a huge difference, since rails caches all the results
of the queries generated by point.trace lookups, but at least it cuts
down on the logs.

app/controllers/api/tracepoints_controller.rb

index 81de17bbcd219c1fceea01888effc782dc099aab..9dc6e0d8b3ca996ff91ae3f846704b42159d22aa 100644 (file)
@@ -33,7 +33,7 @@ module Api
       # get all the points
       ordered_points = Tracepoint.bbox(bbox).joins(:trace).where(:gpx_files => { :visibility => %w[trackable identifiable] }).order("gpx_id DESC, trackid ASC, timestamp ASC")
       unordered_points = Tracepoint.bbox(bbox).joins(:trace).where(:gpx_files => { :visibility => %w[public private] }).order("gps_points.latitude", "gps_points.longitude", "gps_points.timestamp")
-      points = ordered_points.union_all(unordered_points).offset(offset).limit(Settings.tracepoints_per_page)
+      points = ordered_points.union_all(unordered_points).offset(offset).limit(Settings.tracepoints_per_page).preload(:trace)
 
       doc = XML::Document.new
       doc.encoding = XML::Encoding::UTF_8