Avoid ordering points from public and private traces

Closes #2046
This commit is contained in:
Tom Hughes 2018-11-07 08:57:14 +00:00
parent a39c645602
commit cdb42d2a6c
4 changed files with 14 additions and 8 deletions

View file

@ -44,6 +44,7 @@ gem "autoprefixer-rails", "~> 8.6.3"
gem "image_optim_rails"
# Load rails plugins
gem "active_record_union"
gem "actionpack-page_caching"
gem "cancancan"
gem "composite_primary_keys", "~> 11.0.0"

View file

@ -29,6 +29,8 @@ GEM
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.3)
active_record_union (1.3.0)
activerecord (>= 4.0)
activejob (5.2.0)
activesupport (= 5.2.0)
globalid (>= 0.3.6)
@ -66,7 +68,7 @@ GEM
bootsnap (1.3.2)
msgpack (~> 1.0)
builder (3.2.3)
cancancan (2.1.3)
cancancan (2.3.0)
canonical-rails (0.2.4)
rails (>= 4.1, < 5.3)
capybara (2.18.0)
@ -88,7 +90,7 @@ GEM
coffee-script-source (1.12.2)
composite_primary_keys (11.0.3)
activerecord (~> 5.2.0)
concurrent-ruby (1.0.5)
concurrent-ruby (1.1.3)
coveralls (0.8.22)
json (>= 1.8, < 3)
simplecov (~> 0.16.1)
@ -177,7 +179,7 @@ GEM
mini_mime (>= 0.1.1)
marcel (0.3.3)
mimemagic (~> 0.3.2)
method_source (0.9.0)
method_source (0.9.1)
mime-types (3.2.2)
mime-types-data (~> 3.2015)
mime-types-data (3.2018.0812)
@ -255,7 +257,7 @@ GEM
puma (3.12.0)
quad_tile (1.0.1)
r2 (0.2.7)
rack (2.0.5)
rack (2.0.6)
rack-cors (1.0.2)
rack-openid (1.3.1)
rack (>= 1.1.0)
@ -346,7 +348,7 @@ GEM
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
term-ansicolor (1.6.0)
term-ansicolor (1.7.0)
tins (~> 1.0)
terrapin (0.6.0)
climate_control (>= 0.0.3, < 1.0)
@ -356,7 +358,7 @@ GEM
thor (0.19.4)
thread_safe (0.3.6)
tilt (2.0.8)
tins (1.17.0)
tins (1.18.0)
tzinfo (1.2.5)
thread_safe (~> 0.1)
uglifier (4.1.19)
@ -382,6 +384,7 @@ DEPENDENCIES
SystemTimer (>= 1.1.3)
aasm
actionpack-page_caching
active_record_union
annotate
autoprefixer-rails (~> 8.6.3)
better_errors

View file

@ -30,7 +30,9 @@ class ApiController < ApplicationController
end
# get all the points
points = Tracepoint.bbox(bbox).offset(offset).limit(TRACEPOINTS_PER_PAGE).order("gpx_id DESC, trackid ASC, timestamp ASC")
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(TRACEPOINTS_PER_PAGE)
doc = XML::Document.new
doc.encoding = XML::Encoding::UTF_8

View file

@ -22,7 +22,7 @@ module GeoRecord
SCALE = 10000000
included do
scope :bbox, ->(bbox) { where(OSM.sql_for_area(bbox)) }
scope :bbox, ->(bbox) { where(OSM.sql_for_area(bbox, "#{table_name}.")) }
before_save :update_tile
end