[openstreetmap/openstreetmap-website] Move tracepoint ordering logic into tracepoint model, and add tests (#2068)

Tom Hughes notifications at github.com
Tue Nov 20 19:09:44 UTC 2018


tomhughes requested changes on this pull request.



> @@ -39,4 +39,10 @@ def to_xml_node(print_timestamp = false)
     el1 << (XML::Node.new("time") << timestamp.xmlschema) if print_timestamp
     el1
   end
+
+  # Return points of trackable traces in original order
+  scope :trackable_ordered, -> { joins(:trace).where(:gpx_files => { :visibility => %w[trackable identifiable] }).order("gpx_id DESC, trackid ASC, timestamp ASC") }
+
+  # Hide the order of points of non-trackable traces for privacy
+  scope :non_trackable_unordered, -> { joins(:trace).where(:gpx_files => { :visibility => %w[public private] }).order("gps_points.latitude", "gps_points.longitude") }

Can you move these to the top please, for consistency with other models - normally we put scopes immediately after the associations at the top of the model.

As to names I agree with @gravitystorm that these names may be confusing but I'm not sure the ones I suggested are perfect either so I'm not really sure what's best. The goal of my names was just to separate point which could be ordered (as `ordered`) from those which can't (as `unordered`) but I realise that may not be very clear from the names.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/2068#pullrequestreview-176929579
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20181120/c718f463/attachment-0001.html>


More information about the rails-dev mailing list