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

krubokrubo notifications at github.com
Wed Nov 21 07:58:58 UTC 2018


krubokrubo commented 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") }

Ah, I see I missed the model format earlier. Yes, I moved the new scopes to the right location in the model now.

I'm not sure what to suggest for names.  As a newcomer it makes sense to me that identifiable and trackable traces both have the property trackable?==true and are both included in a trackable scope.  `unordered` is trickier---perhaps the ones that have trackable?==false could be called `anonymized` or `non_trackable_anonymized` or just `non_trackable`?  But as I study it more, "public" traces still puzzle me---I don't see the value of anonymizing the points on the map while the trace remains publicly available for download.  I'm guessing this has already been discussed elsewhere.

-- 
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#discussion_r235282910
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20181120/b8f26b70/attachment.html>


More information about the rails-dev mailing list